Frame scripts run on the special JS context for which we call SetSecurityManagerForJSContext with flags=0, thus if a frame script calls into an untrusted function, XPConnect does not do proper security checks.
Created attachment 577241 [details]
screenshot of testcase 3
mrbkap, what kinds of flags can be passed to SetSecurityManagerForJSContext?
There is no documentation in nsIXPConnect nor in nsXPConnect.cpp
I'm pretty sure 0 is passed because it is (or was) passed also here
Ahaa, some documentation is here
Should I pass HOOK_ALL ?
Hey Olli. I don't think you actually need to call SetSecurityManagerForJSContext at all. That function is useful if a given context needs to use a different security manager from the rest of the runtime. However, in most cases, we can just use the one that's installed on XPConnect itself. On the other hand, using HOOK_ALL would also fix this bug.
Created attachment 577535 [details] [diff] [review]
Create a helper method.
Comment on attachment 577535 [details] [diff] [review]
Review of attachment 577535 [details] [diff] [review]:
I mentioned on IRC that the reason that web workers got away with this (before the recent rewrite) is that they truly used object capabilities to protect themselves. Furthermore, they couldn't use the script security manager off the main thread, and therefore wanted to *prevent* calls to the SSM. Because there was nothing around to protect, this was safe.
@@ +840,5 @@
> + JSAutoRequest ar(cx);
> + nsIXPConnect* xpc = nsContentUtils::XPConnect();
> + const PRUint32 flags = nsIXPConnect::INIT_JS_STANDARD_CLASSES |
> + /*nsIXPConnect::OMIT_COMPONENTS_OBJECT ? |*/
I doubt you want this flag. It's only useful if you want to cut the scripts you're going to be running off from XPCOM entirely.
Yeah, that flag has been there since the beginning when it wasn't sure whether we want to
expose components to frame scripts or let them do only simpler things.
I'll remove that.
Created attachment 577960 [details] [diff] [review]
I'll prepare patches for aurora and beta.
Created attachment 578220 [details] [diff] [review]
The only difference to trunk is that trunk doesn't have
In beta there is also JS_SetScriptStackQuota and JSOPTION_ANONFUNFIX |
Now tracking for FF9/10, and added the sec-review-needed keyword. Please address possible risk for taking on aurora/beta.
There is little risk here, we should take this for aurora (fx10)
little risk from the patch, I mean! It's a bad security hole that's probably exploitable through several addons and definitely exploitable through an XSS on AMO.
Verified fixed in Firefox 11.0b6.
Verified fixed in Firefox Aurora.
Verified fixed in Firefox Nightly.