Closed
Bug 313236
Opened 19 years ago
Closed 19 years ago
Access checks in XBL compilation scope can be circumvented
Categories
(Core :: Security, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla1.8rc1
People
(Reporter: moz_bug_r_a4, Assigned: mrbkap)
References
Details
(Keywords: fixed1.7.13, fixed1.8, Whiteboard: [sg:critical])
Attachments
(5 files, 1 obsolete file)
297 bytes,
text/html
|
Details | |
2.34 KB,
patch
|
brendan
:
review+
bzbarsky
:
superreview+
dveditz
:
approval-aviary1.0.8+
dveditz
:
approval1.7.13+
brendan
:
approval1.8rc1+
|
Details | Diff | Splinter Review |
12.21 KB,
patch
|
brendan
:
review+
dveditz
:
approval-aviary1.0.8+
dveditz
:
approval1.7.13+
brendan
:
approval1.8rc1+
|
Details | Diff | Splinter Review |
5.94 KB,
patch
|
Details | Diff | Splinter Review | |
8.41 KB,
patch
|
brendan
:
review+
|
Details | Diff | Splinter Review |
The fix for Bug 312871 can be circumvented. I've tested on trunk 2005-10-20-07.
Content can access objects in XBL compilation scope via a object that has XBL
compilation scope object in its proto chain.
<marquee id="m">marquee</marquee>
m = document.getElementById("m");
x = m.init.valueOf.call(null);
y = { __proto__ : x };
y.Function;
Reporter | ||
Comment 1•19 years ago
|
||
Assignee | ||
Comment 2•19 years ago
|
||
I think I have a handle on this. The basic problem is that getting object
principals walks the _parent_ chain, but looking up properties and such (like
the Function object) walks the _proto_ chain.
We need to make sure to use the right object for the access checks.
Assignee: dveditz → mrbkap
Assignee | ||
Updated•19 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Updated•19 years ago
|
Flags: blocking1.8rc1?
Priority: -- → P1
Target Milestone: --- → mozilla1.8rc1
Assignee | ||
Comment 3•19 years ago
|
||
I was tempted to turn the if (!obj) clause into an assertion, but settled on an
XXX with an if. Is there an actual case where that can happen? Otherwise, this
patch works (and is correct, I think: I should have remembered from looking at
the object ops for native wrappers).
Attachment #200330 -
Flags: review?(brendan)
Comment 4•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
patch looks good, but how many more unplugged holes do we have in these dikes?
Is there a better, simpler, more reliable way to re-do the whole mechanism?
(not for the 1.8 branch, obviously.)
Comment 5•19 years ago
|
||
code execution exploit, taking the liberty of marking blocking.
Flags: blocking1.8rc1?
Flags: blocking1.8rc1+
Flags: blocking1.7.13+
Flags: blocking-aviary1.0.8+
Whiteboard: [sg:critical]
Comment 6•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
>+ // Make sure to actually operate on our object, and not some object further
>+ // down on the proto chain.
>+ while (JS_GET_CLASS(cx, obj) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
>+ obj = ::JS_GetPrototype(cx, obj);
>+ if (!obj) {
>+ // XXX Eh?
Since __proto__ is mutable you shouldn't XXX here. This can happen if someone
can set __proto__ on the object that delegates to the XBL compilation scope to
null.
Question: what object is it, of what class, that delegates to the XBL
compilation scope along __proto__, yet is reached along the __parent__ linked
scope chain?
/be
Assignee | ||
Comment 7•19 years ago
|
||
I'm pretty sure it was y (class "Object").
Comment 8•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
We talked about adding belt and braces to Function, a la eval and Script, in a
separate patch.
/be
Attachment #200330 -
Flags: review?(brendan) → review+
Assignee | ||
Updated•19 years ago
|
Attachment #200330 -
Flags: superreview?(bzbarsky)
![]() |
||
Updated•19 years ago
|
Attachment #200330 -
Flags: superreview?(bzbarsky) → superreview+
Comment 9•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
+ friend JSBool doCheckAccess(JSContext *cx, JSObject *obj, jsval id,
+ PRUint32 accessType);
Maybe make doCheckAccess a static member of this class to avoid the friend
declaration here?
sr=jst with that. bz, feel free to double check this if you've got a moment...
Assignee | ||
Comment 10•19 years ago
|
||
I'm worried that this is going to break some native caller somewhere who is
silly enough to not provide a scripted caller but still wants Function to do
the right thing, but it doesn't look like there are any obvious callsites that
do that.
Assignee | ||
Updated•19 years ago
|
Attachment #200391 -
Flags: review?(brendan)
Comment 11•19 years ago
|
||
Comment on attachment 200391 [details] [diff] [review]
A belt to go with those braces
> #if JS_HAS_EVAL_THIS_SCOPE
> /* If obj.eval(str), emulate 'with (obj) eval(str)' in the caller. */
> if (indirectCall) {
> callerScopeChain = caller->scopeChain;
> if (obj != callerScopeChain) {
>- if (!CheckEvalAccess(cx, obj, caller->script->principals))
>+ if (!js_CheckPrincipalsAccess(cx, obj,
>+ caller->script->principals,
>+ js_eval_str))
> return JS_FALSE;
Brace if any of if or loop condition, then, else or body is multiline, for
home-style cooking.
>+ /*
>+ * Belt-and-braces: Be
lowercase "be"
> absolutely certain that the caller can access the
s/can/should be able to/
or something like that, because if we got here, the caller *can* access the
Function, our belt is off, and our pants are down unless these braces hold. ;-)
>+ * parent of this function to avoid returning a function with stronger
>+ * principals than the caller should be receiving.
>+ */
>+ if (!js_CheckPrincipalsAccess(cx, parent, principals, "Function"))
>+ return JS_FALSE;
>@@ -310,31 +309,22 @@ script_exec(JSContext *cx, JSObject *obj
>
> OBJ_TO_INNER_OBJECT(cx, scopeobj);
> if (!scopeobj)
> return JS_FALSE;
>
> if (!js_CheckScopeChainValidity(cx, scopeobj, js_script_exec))
> return JS_FALSE;
Hey, perfect time to push OBJ_TO_INNER_OBJECT(cx, scopeobj) down into
js_CheckScopeChainValidity, here and in obj_eval.
I'll look again if you want to put a new patch in, r=me with these fixes right
now.
/be
Attachment #200391 -
Flags: review?(brendan) → review+
Assignee | ||
Comment 12•19 years ago
|
||
Attachment #200391 -
Attachment is obsolete: true
Attachment #200400 -
Flags: review?(brendan)
Comment 13•19 years ago
|
||
Comment on attachment 200400 [details] [diff] [review]
Shinier belt
Great, thanks!
/be
Attachment #200400 -
Flags: review?(brendan)
Attachment #200400 -
Flags: review+
Attachment #200400 -
Flags: approval1.8rc1+
Assignee | ||
Comment 14•19 years ago
|
||
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•19 years ago
|
Attachment #200330 -
Flags: approval1.8rc1?
Comment 15•19 years ago
|
||
are we still interested in the earlier "Fix." patch? If not, can one of you
remove the approval request?
Assignee | ||
Comment 16•19 years ago
|
||
Asa, we want both fixes here.
Comment 17•19 years ago
|
||
Right, we want belt, and braces. We have it for eval and Script, and this pair
of patches gives us the same for Function.
/be
Comment 18•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
We want the checked-in version of this from the trunk, on the branch, in a larger roll-up patch, with a generic checkin message.
/be
Attachment #200330 -
Flags: approval1.8rc1? → approval1.8rc1+
Updated•19 years ago
|
Flags: testcase+
Comment 20•19 years ago
|
||
Comment on attachment 200330 [details] [diff] [review]
Fix.
aviary101/moz17 landing approval: a=dveditz for drivers. Please add the fixed1.7.13 and fixed-aviary1.0.8 keywords when landed.
Attachment #200330 -
Flags: approval1.7.13+
Attachment #200330 -
Flags: approval-aviary1.0.8+
Updated•19 years ago
|
Attachment #200400 -
Flags: approval1.7.13+
Attachment #200400 -
Flags: approval-aviary1.0.8+
Assignee | ||
Comment 21•19 years ago
|
||
I'm about to check this into the 1.7 branches. It includes this fix and the fix for bug 312871.
Assignee | ||
Comment 22•19 years ago
|
||
Checked into the 1.7 branches. (I still need to check the shinier belt in though).
Keywords: fixed-aviary1.0.8,
fixed1.7.13
Assignee | ||
Comment 23•19 years ago
|
||
This backports the belt and braces patch.
Attachment #211336 -
Flags: review?(brendan)
Comment 24•19 years ago
|
||
Comment on attachment 211336 [details] [diff] [review]
Belt backported
Looks good to me.
/be
Attachment #211336 -
Flags: review?(brendan) → review+
Assignee | ||
Comment 25•19 years ago
|
||
I checked the backported belt into the 1.7 branches.
Comment 26•19 years ago
|
||
v.fixed on 1.0.1 Aviary branch with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.13) Gecko/20060213 Firefox/1.0.8, permission denied in testcase.
Keywords: fixed-aviary1.0.8 → verified-aviary1.0.8
Updated•19 years ago
|
Group: security
Updated•18 years ago
|
Flags: in-testsuite+ → in-testsuite?
You need to log in
before you can comment on or make changes to this bug.
Description
•