Closed Bug 619403 Opened 15 years ago Closed 15 years ago

Java-based CSRF vulnerability in addons.mozilla.org

Categories

(addons.mozilla.org Graveyard :: Developer Pages, defect)

defect
Not set
critical

Tracking

(Not tracked)

VERIFIED FIXED
5.12.10

People

(Reporter: neal, Assigned: clouserw)

References

()

Details

(Keywords: reporter-external, wsec-csrf, Whiteboard: [infrasec:csrf][ws:critical])

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 Build Identifier: I'm reporting this under the terms of the Web Application Security Bug Bounty program (http://www.mozilla.org/security/bug-bounty-faq-webapp.html). addons.mozilla.org is vulnerable to a malicious attacker uploading a .jar file containing Java code. Due to Java's same-origin policy, Java code hosted on a domain can make requests back to that same domain (using that domain's cookies) regardless of where the actual <applet> HTML is. An attacker simply has to bundle a valid install.rdf with a malicious Java class inside of a .jar file. The Addons site will accept the upload (with a warning about the .class file) and serve the JAR directly from https://addons.mozilla.org A proof of concept that returns the currently logged in user's CSRF token can be found at http://nealpoole.com/d4db563417b2664443dd16afffb05199.html Reproducible: Always Steps to Reproduce: 1. Create malicious .jar file (evil .class file, good install.rdf) 2. Upload as Firefox extension 3. Get URL, create page on arbitrary third party domain containing <applet> tag 4. Get logged in addons.mozilla.org users to visit your page 5. Make arbitrary requests on their behalf
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86_64 → All
Target Milestone: --- → 5.12.5
Would this work if the package extension is XPI instead of JAR? XPI works equally well for themes and we could begin rejecting JAR submissions. I hope there's something that can be done on the site to prevent this kind of attack, though.
Unfortunately, it does. I renamed the extension from JAR to XPI and uploaded: I encountered the same verification process, the upload was allowed, and the applet tag accepted it as a JAR file. This is an identical proof of concept to the original, except using the XPI file instead of the JAR: http://nealpoole.com/d4db563417b2664443dd16afffb05199-2.html
Generally, the way I've seen this dealt with is to put user uploads on a separate, sandboxed domain. Google uses domains like googleusercontent.com to serve the actual files: even if an attacker can upload content to that domain, it doesn't get them anywhere, since nobody has cookies or sessions on that domain.
Alternatively, if you can scan the entire list of files in an archive, one way to mitigate the vulnerability might be to prevent any uploads where the archive contains a file with a .class extension. From my testing, it appears that Java will not load a class that lacks the .class extension. So, if the archives can't contain files ending in .class, no Java can be run.
Unfortunately, Java code is something we allow in add-ons, so we can't forbid it without breaking a number of them.
We should host all files elsewhere as suggested. mozillauserfilesforyou.com
(In reply to comment #5) > Unfortunately, Java code is something we allow in add-ons, so we can't forbid > it without breaking a number of them. Ah, I didn't realize that. My apologies. Then yes, hosting on a separate domain is the safest solution.
It's worth noting that (apparently) Java applets don't have access to HttpOnly cookies. I'm unsure whether this is a bug or a feature, but it is the current behavior. So, using HttpOnly cookies for the website would mitigate the session hijacking in its current form. Sources: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6890023 http://blog.mindedsecurity.com/2010/10/java-applet-same-ip-host-access.html
It's worth mentioning that the file should never be accessible from the addons.mozilla.org hostname, even temporarily. For instance, when an extension is being validated (before the author chooses to accept it), it appears to be placed at https://addons.mozilla.org/_files/temp/FILENAME. It's never linked to at that location and I don't think people are meant to be able to access it directly: however, it's still there.
The Java spin on this bug is interesting, thanks for filing. The current plan is to use mozilla.net for this (coming in bug 617683). That's a mirror of the code, so it'll be easy enough to change the URL to redirect there. We'd only allow /_files/ urls (aside from temp - that should never be available), and the other CDN stuff we want like images/css/js. Anyone have concerns with that plan?
Depends on: 617683
Target Milestone: 5.12.5 → 5.12.6
Whiteboard: [ws:critical]
Depends on: 587065
Filed some blockers for this tonight and confirmed the new validator only extracts files to the system temp dir (found using python's tempdir lib).
Target Milestone: 5.12.6 → 5.12.7
Assignee: nobody → clouserw
Blockers are progressing. First bug 621827 which blocks bug 587065 which blocks this. Also blocking this are bug 626931 and bug 627041. I expect we'll close 3 of those today so I'll save you all the bugspam and not tell bugzilla about the dependencies.
Target Milestone: 5.12.7 → 5.12.8
Still plugging through those blockers and testing stuff on addons.allizom.org. The CDN is actually enabled there at this point, will probably enable in production next week or the week after
Target Milestone: 5.12.8 → 5.12.10
Alright, I think we are good here. There are two possible options for file downloads right now - files that have been reviewed (and are on the mirror network) and files that haven't been. Files that haven't been (eg. https://addons.mozilla.org/en-US/firefox/addon/pagerank/) follow this flow: - GET https://addons.mozilla.org/_files/271839/pagerank-1.1-fx.xpi = 301 - GET https://static.addons.mozilla.net/_files/271839/pagerank-1.1-fx.xpi = 200 Files that have been (eg. https://addons.mozilla.org/en-US/firefox/addon/adblock-plus/) follow this flow: - GET https://addons.mozilla.org/firefox/downloads/latest/1865/addon-1865-latest.xpi?src=addondetail = 301 - GET https://addons.mozilla.org/firefox/downloads/latest/adblock-plus/addon-adblock-plus-latest.xpi?src=addondetail = 302 - GET https://addons.mozilla.org/firefox/downloads/file/106309/type:None/adblock_plus-1.3.3-fn+fx+sm+tb.xpi?src=addondetail = 302 - GET http://releases.mozilla.org/pub/mozilla.org/addons/1865/adblock_plus-1.3.3-fn+fx+sm+tb.xpi = 200 There is a rewrite to 301 anything going to /_files/ to the .net domain. The public add-ons are still released on releases.m.o but they've been reviewed. Calling this fixed, please verify/review.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Are we totally complete here? Everything pushed in prod and working correctly? If so, I'd like this bug to move to "VERIFIED"
Fixed from my point of view. Someone please double check
There were concerns raised in bug 633774. Other than that, everything is OK.
Verified comment 15 approach with testing on prod.
Status: RESOLVED → VERIFIED
Whiteboard: [ws:critical] → [infrasec:csrf][ws:critical]
Keywords: wsec-csrf
Flags: sec-bounty+
Product: addons.mozilla.org → addons.mozilla.org Graveyard
Group: client-services-security
You need to log in before you can comment on or make changes to this bug.