Closed
Bug 77485
Opened 24 years ago
Closed 23 years ago
function definition isn't subject to domain checks (exploit involves targeted javascript links)
Categories
(Core :: Security: CAPS, defect, P2)
Core
Security: CAPS
Tracking
()
VERIFIED
FIXED
mozilla0.9.3
People
(Reporter: jruderman, Assigned: security-bugs)
Details
Attachments
(11 files)
1.27 KB,
text/html
|
Details | |
3.31 KB,
patch
|
Details | Diff | Splinter Review | |
2.05 KB,
patch
|
Details | Diff | Splinter Review | |
6.55 KB,
patch
|
Details | Diff | Splinter Review | |
2.09 KB,
patch
|
Details | Diff | Splinter Review | |
1.56 KB,
text/html
|
Details | |
4.70 KB,
patch
|
Details | Diff | Splinter Review | |
4.54 KB,
patch
|
Details | Diff | Splinter Review | |
2.04 KB,
text/html
|
Details | |
3.42 KB,
patch
|
Details | Diff | Splinter Review | |
9.33 KB,
patch
|
Details | Diff | Splinter Review |
Using a link targeted to a frame at another domain, I can create a function in
another domain and then call that function. Once the function is at the other
domain, it runs with the privileges of that domain regardless of who calls it.
There are two ways to exploit this hole:
1. Name the function focus(), blur(), or close(). These functions will be
callable cross-domain once bug 65012 (focus/blur) and bug 62168 (close) are
fixed.
2. Call the function as part of the same statement that defines the function.
In this case, the function name doesn't matter (it can even be nameless).
Both exploits require getting the victim to click on a link targeted to another
frame or window (which shouldn't be too hard).
The problem seems to be that there's no domain check for statements or
expressions like
function [name] (...) { ... }.
Btw, IE doesn't allow javascript: links to be targeted to another domain.
Netscape 4 and Mozilla do allow them, using the principal of the linking window
and the scope of the target window. I think that feature was added to Mozilla
in bug 25821 (see Brendan Eich's 2000-10-31 19:52 comment).
Reporter | ||
Comment 1•24 years ago
|
||
Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.1
Assignee | ||
Comment 2•24 years ago
|
||
Assignee | ||
Comment 3•24 years ago
|
||
The above patch fixes the first testcase - the function will run with the
principals of the attack page, not the target page. In the second testcase, I
think we have another how-to-get-principals issue. Tracing through
nsScriptSecurityManager::GetSubjectPrincipal, called from canAccess() on the
access to document.links, I see that the loop in GetPrincipalAndFrame skips the
innermost frame, as it should because this is an XPConnect call. On the second
iteration, the call to GetFunctionObjectPrincipal sees a cloned, non-native
function and calls GetObjectPrincipal accordingly. This seems to be wrong in
this case. GetObjectPrincipal looks at the function object's scope, which leads
to the target document (not what we want) since the function was defined in the
target scope. If we instead call GetScriptPrincipal, as we normally do for
functions that are not cloned, we get the attacking page's principal, under
which the function was compiled, which is what we want.
I'm not sure how to distinguish this case from the normal case of a cloned
function in which we don't want to call GetScriptPrincipal. Brendan, can you advise?
To reproduce the bug, load Jesse's testcase, click the first link on the page to
load the target page, then click the last link on the page. You may have to
apply my patch to see the behavior I just described.
Comment 4•24 years ago
|
||
r=jst for the attached patch.
Comment 5•24 years ago
|
||
mstoltz: we need a flag in our principal base class that says "if I'm the
principal of a cloned function object's script -- a compile-time subject
principal, IOW -- use the clone's scope chain to find a global object with the
right principal when backtracing through an activation of the clone".
There is no other way to distinguish the XUL/XBL case (where we want to set this
flag) from the HTML one (where the flag is clear by default initialization).
So we'll need to whack the XUL script-compiling code, too. Should we always set
this flag on the system principal?
/be
Comment 6•24 years ago
|
||
I didn't know we allowed cross-domain calls to focus, blur, etc. Can we insist
that those name native methods before allowing conditional access? That would
beef up our story a bit.
/be
Comment 7•24 years ago
|
||
On the patch: don't comment out code with C-style comments, do remove it if it's
extremely likely to be gone (CVS will remember), or use #if 0 and an XXX comment
if you're 50-50 on its going away for good.
@@ -3800,7 +3835,7 @@
return NS_OK;
}
}
-
+/*
nsCOMPtr<nsISupports> owner(aOwner);
//
// Check to see if an owner should be inherited...
@@ -3835,7 +3870,7 @@
GetCurrentDocumentOwner(getter_AddRefs(owner));
}
}
-
+*/
/be
Assignee | ||
Updated•24 years ago
|
Whiteboard: fix expected by 5/25
Assignee | ||
Comment 8•24 years ago
|
||
I'm not sure if it's safe to set the flag you describe on the principal class,
since principals are sometimes shared. Any two requests for the principal for a
given URL will return a pointer to the same object under certain circimstances.
Did you mean to put that flag on the JSPrincipals struct? I think those aren't
shared (but maybe you know differently).
If I understand correcly, you're saying we should set a flag on the principal
that tells us whether or not to get principals from the function's scope if the
function is cloned? Do you know where in the XUL/XBL code this flag needs to be set?
Assignee | ||
Comment 9•24 years ago
|
||
Assignee | ||
Comment 10•24 years ago
|
||
Assignee | ||
Updated•24 years ago
|
Whiteboard: fix expected by 5/25 → have fix, need reviews
Assignee | ||
Comment 11•24 years ago
|
||
Comment 12•24 years ago
|
||
sr=jst & r=vidur
Assignee | ||
Updated•24 years ago
|
Whiteboard: have fix, need reviews → waiting for driver approval
Comment 13•24 years ago
|
||
a= asa@mozilla.org for checkin to 0.9.1 on behalf of drivers.
Assignee | ||
Updated•24 years ago
|
Whiteboard: waiting for driver approval → Fix checked in, waiting for verification builds before closing bug
Comment 14•24 years ago
|
||
lets not make up a new process... when the fix gets checked in
lets mark the bugs fixed, and reopen if the fix doesn't work.
marking bugs fixed gets them on the regression testing radar.
ckritzer, can you jump on this in build the builds from
wed. morning?
thanks
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 15•24 years ago
|
||
are there other areas outside the demostration test case that should
get a good shaking out?
Comment 16•24 years ago
|
||
Jesse took a look at this with me on today's builds, and there's still some odd
things going on. For example, the function can be run in the location field,
and will show the number of links on Amazon's page (this would be bad).
However, we do seem to be checking for domain and denying cross domain from the
originating page.
Comment 17•24 years ago
|
||
I'm updating the Platform/OS to ALL/ALL, unless Jesse objects.
OS: Windows 98 → All
Hardware: PC → All
Assignee | ||
Comment 18•24 years ago
|
||
Despite the fact that there's still some odd behavior, I suggest we take this
off the 0.9.1 radar and fix this more comprehensively for 0.9.2. The most
serious exploit has been fixed. Chris, Jesse, do you think this is OK, or is
this serious enough to hold up 0.9.1?
Target Milestone: mozilla0.9.1 → mozilla0.9.2
Comment 19•24 years ago
|
||
I'll defer judgement to Jesse, as it is his bug, and he better understands the
workings as such.
Jesse?
Assignee | ||
Comment 20•24 years ago
|
||
Jesse thinks this is not a beta stopper.
Comment 21•24 years ago
|
||
Right, so after speaking with Mitch, we're keeping this open for now, and
targeting it for 0.9.2.
Reporter | ||
Comment 22•24 years ago
|
||
Reporter | ||
Comment 23•24 years ago
|
||
Reopening. A malicious page can no longer run code with the principal of
another domain, but it can still replace a function in another domain with one
that reports its parameters to the attacker. Cross-domain function definition
should be blocked, just like cross-domain variable definition is blocked.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: mozilla0.9.2 → ---
Assignee | ||
Updated•24 years ago
|
Status: REOPENED → ASSIGNED
Whiteboard: Fix checked in, waiting for verification builds before closing bug
Assignee | ||
Updated•24 years ago
|
Priority: -- → P1
Target Milestone: --- → mozilla0.9.3
Assignee | ||
Comment 24•24 years ago
|
||
Adding nsBranch keyword as these bugs need to get into RTM.
Keywords: nsBranch
Comment 25•24 years ago
|
||
Assignee | ||
Comment 26•24 years ago
|
||
There are two bad things happening: one is that the same-origin check isn't
happening when we replace a function property in another domain using |function
foo() { ... }|. The other is that targeted javascript: links can be used to
insert JS code into a window with content from another domain. Fixing either one
of these problems prevents this particular exploit, but fixing them both
probably fixes some other exploits we don't know about, and generally makes
things safer. jst's patch above fixes the first problem, and the patch I'm about
to post fixes the second, and I'd like to see them both get onto the branch.
r=mstoltz on jst's patch.
Assignee | ||
Comment 27•24 years ago
|
||
Assignee | ||
Comment 28•24 years ago
|
||
A bit of explanation: the last patch compares the principal of the script about
to be run (the body of the JS URL) with the principal of the window it will be
run in. In order to get that second bit of data, I had to add
nsScriptSecurityManager::GetObjectPrincipal() to the public interface, hence the
IDL change.
Comment 29•24 years ago
|
||
1) Double check for \t
2) Please break if(xxx) yyy; into two lines i.e.
if(xxx){
yyy;
}
3) Make sure to null check ptrs ( global & scriptContext )
4) If the return value is not important then there is no need for an assignment.
That is,
nsCOMPtr<nsIPrincipal> systemPrincipal;
+ rv = securityManager->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
Do you care for rv here?
5) Replace NS_FAILED(objectPrincipal->Equals(principal, &equals)) with
nsresult res = objectPrincipal->Equals(principal, &equals);
NS_FAILED(res)
r=harishd
Comment 30•24 years ago
|
||
What Harish said sr=jst.
Michell, once this goes into the branch you'll haveto hand apply this patch
since the JS protocol handler is quite a different place on the branch, but the
same change should work just as well there.
Assignee | ||
Comment 31•24 years ago
|
||
Checked in on the trunk; the changes should be in today's dailies. I'd like to
get this in on the branch today if possible.
Comment 32•24 years ago
|
||
Attaching Testcase to test if Javascript URL's are working fine or not.
Tom asked me to test JS URL's for this one. So just thought I'll attach one
testcase to test JS URL's here & everyone can use it to test if JS URL's are
working fine or not.
Simple testcase is following.
Comment 33•24 years ago
|
||
Assignee | ||
Comment 34•24 years ago
|
||
Assignee | ||
Comment 35•24 years ago
|
||
The patch I just added makes the JS-consle warning I just added to
nsJSProtocolHandler.cpp properly localizable. The patch contains the new
manifest and resource files I added to do this, and a change in build/mac which
should build the locale jar on the Mac. I have not tested the Mac part yet; it
works fine on WinNT. Neither this nor the previous two patches have been checked
into the branch; after everything checks out OK on the trunk, we can combine
them into one patch for the branch.
Johnny, is it OK to add a jar.mn file and a resources directory to the dom
directory?
Comment 36•24 years ago
|
||
Fine with me, sr=jst
Updated•24 years ago
|
Whiteboard: [PDT+]
Comment 37•24 years ago
|
||
Looks like we have patch, r=, and sr=, can this be landed today?
Whiteboard: [PDT+] → [PDT+] patch ready
Comment 38•24 years ago
|
||
yup, I am working on integrating this into the branch as I type. Mitch is away
on vacation today and tomorrow.
Comment 39•24 years ago
|
||
I tested javascript URL's with fridays trunk builds [2001-07-13-07-trunk] on
win-2000.
I tested it with testcase I attached earlier, & javascript URL's seem to be
working fine on that builds.
Updated•24 years ago
|
Whiteboard: [PDT+] patch ready → [PDT+] ETA: 7/16 by 9 pm
Comment 40•24 years ago
|
||
Comment 41•24 years ago
|
||
I just checked in http://bugzilla.mozilla.org/showattachment.cgi?attach_id=42486
into the 6.1 branch.
Mitch, I decided against checking in the localization fix because we haven't
tested it on the trunk and it involves build changes. I don't want to risk
breaking any branch build tonight, the night before we make the rtm candidate
builds. Since we have other JS security error messages that aren't localized,
this change isn't critical for 6.1.
I've left this bug open so that you can check in the localization patch
(http://bugzilla.mozilla.org/showattachment.cgi?attach_id=42249) on the trunk.
Lets also try to localize the other security warnings in time for 0.9.3.
Comment 42•24 years ago
|
||
Removing PDT+ marker now that the fix is on the branch so that this gets off the
PDT radar.
Whiteboard: [PDT+] ETA: 7/16 by 9 pm
Updated•24 years ago
|
Whiteboard: fix checked in on the branch. localization patch needs to go on the trunk
Assignee | ||
Comment 44•24 years ago
|
||
Target is now 0.9.4, Priority P2.
Priority: P1 → P2
Target Milestone: mozilla0.9.3 → mozilla0.9.4
Assignee | ||
Comment 46•24 years ago
|
||
time marches on. Retargeting to 0.9.6.
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Assignee | ||
Comment 47•24 years ago
|
||
Moving the most time-critical bugs and minor security fixes to 0.9.7
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Assignee | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Assignee | ||
Updated•24 years ago
|
Summary: function definition isn't subject to domain checks (exploit involves targeted javascript links) → Localize JS URL security warning
Whiteboard: fix checked in on the branch. localization patch needs to go on the trunk → patch
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Assignee | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9.9 → mozilla1.0
Comment 48•23 years ago
|
||
Moving Netscape owned 0.9.9 and 1.0 bugs that don't have an nsbeta1, nsbeta1+,
topembed, topembed+, Mozilla0.9.9+ or Mozilla1.0+ keyword. Please send any
questions or feedback about this to adt@netscape.com. You can search for
"Moving bugs not scheduled for a project" to quickly delete this bugmail.
Target Milestone: mozilla1.0 → mozilla1.2
Reporter | ||
Comment 49•23 years ago
|
||
Posted bug 129814 for the left-over localization patch, marking this bug as fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago → 23 years ago
Resolution: --- → FIXED
Summary: Localize JS URL security warning → function definition isn't subject to domain checks (exploit involves targeted javascript links)
Whiteboard: patch
Target Milestone: mozilla1.2 → mozilla0.9.3
Comment 50•23 years ago
|
||
ok this is resolved, but what's with the mozilla0.9.3 target????
Reporter | ||
Comment 51•23 years ago
|
||
Basic: 0.9.3 was a guess based on the date this bug was fixed.
Comment 52•23 years ago
|
||
Verified on 2002-04-02-Trunk build on WinNT.
1. Loaded 2 test cases of Jesse. Seem to perform fine.
2. Loaded test case provided by Prashant. Seem to work fine.
Status: RESOLVED → VERIFIED
QA Contact: ckritzer → bsharma
Updated•20 years ago
|
Flags: testcase+
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
•