-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classcache must honor current security context. #1019
Conversation
# Conflicts: # src/org/mozilla/javascript/ClassCache.java # src/org/mozilla/javascript/JavaMembers.java
This looks basically good to me. I don't regularly work with the security framework so I'll assume that you know it well enough to ensure that ".equals" is a good way to compare security contexts. Before we merge this, I really would like you to write a test. It can use a mock security context, or FWIW it can just use an arbitrary object as the "security context" but I think that we need something that covers the code here, including the testing in various cases. Thanks! |
I can write a test for this |
I've added a testcase for the code change. 0e01d89 /edit: have to investigate why test runs in eclipse but not gradle |
The standard implementation of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this looks good -- thanks for writing complete tests. I just have one tiny nit (below) and it's ready to merge. Thanks!
testsrc/org/mozilla/javascript/tests/SecurityControllerTest.java
Outdated
Show resolved
Hide resolved
Thanks! |
Hello,
Apparently most of the time is spent handling the exception introduced by this PR : `private static Object getSecurityContext() {
Indeed, we never run with allPermession, and it rightly seems that the check is performed as soon as a java variable is accessed. As far as we're concerned, the Security Manager's permissioning doesn't change during the entire JVM runtime, so why isn't this test performed once for all? |
Hello @pKrav75 Yes, I see, that handling the exception may consume a lot of time. The idea behind the code was, that all JavaMember.lookupClasses are put in the same slot, if the current AccessControlContext has all permissions. Unfortunately, it is only possible to detect this, if
IMHO each invocation has to get the current AccessControlContext from the SecurityManager. It depends on the current call stack, so the check looks OK for me.
Sure, but I think the SecurityManager will be removed in Rhino 2.0 because it is deprecated and I don't know, if it is planned to make a 1.7.x release (maybe @gbrail has a schedule for this?) So I don't know, if a PR will get merged. It's sad that the SecurityManager is deprecated, but I can understand the JDK developers because the SecurityManager concept is very complicated and doesn't offer 100% security (Please read related issues #1045 #972 #1363 and #1353) I know that's not exactly the answer you want to hear, but you have to face reality and live with the fact that a security concept based on the SecurityManager no longer has a future. (It was also no easy task for us) |
Thank you for your prompt reply. Thanks again for your responsiveness :-) |
Hello, we use different security contexts when executing javascript.
In different security contexts, different methods are allowed to call. We distinguish between restricted (=safe) and unrestricted (=dangerous) methods.
We noticed, that the ClassCache uses only the class as key and caches the visible methods on first invocation.
If this was done in a restricted context, it is not possible to call some unrestricted methods in an unrestricted context later, as the cache will be hit.
The same is, if the class was loaded in an unrestricted securitycontext, you can call unrestricted methods in a restricted context.
With this PR, the cache takes the current security context (in detail, the
java.security.Permission
s) into account, when caching classes.Please review and give me feedback.