Open Bug 858721 Opened 12 years ago Updated 3 years ago

UXSS using carefully timed history navigations

Categories

(Core :: DOM: Navigation, defect)

20 Branch
defect

Tracking

()

People

(Reporter: marius.mlynski, Assigned: smaug)

Details

(Keywords: sec-audit, Whiteboard: [dupe of bug 848253?])

Attachments

(2 files, 1 obsolete file)

It is possible to load an arbitrary website contained in an iframe such that its document's baseURI points to the attacker's location. This allows cross-site scripting when the targeted page loads a script via a relative path.
Attached file Exploit
This gets document.cookie for usa.bnpparibas.com. Usage: 1. Upload the exploit to a server that doesn't auto-redirects on file access. This is a fragile piece of code stressing edge conditions, and any unexpected element in the navigation chain will break it (as was the case for previous PoC's running directly from bmo). 2. Upload the /common/ directory to the root of the web server. 3. Run /exploit/index.html. It takes about 15 seconds to complete. I've tested in Firefox 20 and the latest Nightly.
Attachment #734010 - Attachment mime type: application/octet-stream → application/zip
this seems like an extreme corner case so I am thinking sec-moderate at best, assigning to mgoodwin to verify and look over
Assignee: nobody → mgoodwin
Whiteboard: [verif?]
What in particular makes this a corner-case?
If he's achieving universal XSS, this seems clearly sg-high to me, no matter how fiddly the testcase may be. That's how we flagged all of the previous bugs that are similar to this one (there have been many).
Keywords: sec-high
Attached file Exploit - Wikipedia (obsolete) —
Granted, a random bank website isn't too impressive as a XSS target. Here's an exploit for Wikipedia. I've made a minor timing fix, so if you experience problems with the previous testcase, try this one out.
Attachment #734067 - Attachment mime type: application/octet-stream → application/zip
Attached file Exploit - Wikipedia
I missed that the injected code fails to load when the file being swapped is cached and Wikipedia hasn't been loaded earlier in the browsing session. I'm attaching a (hopefully) final version that works around this issue.
Attachment #734067 - Attachment is obsolete: true
Attachment #734404 - Attachment mime type: application/octet-stream → application/zip
Is this related to the fact that we get the script entry point wrong in this case? If so, this is probably a more interesting attack using the same underlying bug as bug 810808. We basically need to implement the script entry point stack properly here.
I'm not actually convinced that this uses the same bug as 810808. Cursorily, it looks like the exploit gets around the history-object blocking by doing history.back() on the window he controls, and relying on the fact that that navigates the cross-origin iframe.
(In reply to Justin Lebar [:jlebar] from comment #8) > I'm not actually convinced that this uses the same bug as 810808. > > Cursorily, it looks like the exploit gets around the history-object blocking > by doing history.back() on the window he controls, and relying on the fact > that that navigates the cross-origin iframe. Wait, can History.back cause descendant docshells to navigate as well? I thought that whenever we navigated a docshell node all child nodes went away.
> Wait, can History.back cause descendant docshells to navigate as well? Yeah, you can test with > data:text/html,<button onclick="history.back()">Back</button><iframe src="http://wikipedia.org">
history.back() goes one step back in the history. There is one history per toplevel navigation context (aka tab). back() anywhere in the navigation context tree will, iirc, navigate whatever frame in that navigation context tree last navigated or something.
(In reply to Boris Zbarsky (:bz) from comment #11) > history.back() goes one step back in the history. There is one history per > toplevel navigation context (aka tab). back() anywhere in the navigation > context tree will, iirc, navigate whatever frame in that navigation context > tree last navigated or something. Which means that restricting the history object to same-origin pages does nothing to protect us from attacks, unless we also change how history.back works. :(
Yikes. Does our history.back behavior match the spec? I just spent some time reading the session history stuff in the spec, but my eyes glazed over before I got a full picture. I can dig more if nobody knows that part of the spec well, I guess.
Olli, can you maybe take a look at this? Thanks.
Assignee: mgoodwin → bugs
The exploits stopped working in Nightly 2013-05-16. At a glance, the caching behaviour was changed such that the PoC's no longer navigate to the target site after the final call to history.back(). I think this may be a side effect of the following code revision: https://hg.mozilla.org/mozilla-central/rev/1695bdfbfa8e
Oh, is this a dup of Bug 848253. I'll investigate.
As this looks like a dupe of another fixed bug, and is being left open so Olli can take a look into it, I'm going to mark this sec-audit.
Keywords: sec-highsec-audit
Whiteboard: [dupe of bug 848253?]
Group: core-security → dom-core-security
Group: dom-core-security
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: