Closed Bug 825641 Opened 13 years ago Closed 11 years ago

Host-header password reset poisoning attack

Categories

(addons.mozilla.org Graveyard :: Administration, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: albinowax, Unassigned)

References

Details

(Keywords: reporter-external, sec-high, Whiteboard: [infrasec:auth][ws:high])

A variation of the poisoned password reset attack described in https://bugzilla.mozilla.org/show_bug.cgi?id=741740 is still possible, due to an apparent server issue with the server's host whitelist. A direct attack like: POST /en-US/firefox/users/pwreset HTTP/1.1 Host: evil.com will fail. However, it's possible to confuse nginx by placing the full URI in the first line: POST https://addons.mozilla.org/en-US/firefox/users/pwreset HTTP/1.1 Host: evil.com Resulting in a poisoned reset link: https://evil.com/users/pwreset/3ocig/<token_removed>
Component: Developer Pages → Administration
Keywords: sec-high
See Also: → 741740
Whiteboard: [infrasec:auth][ws:high]
Flags: sec-bounty?
James (Bennett): is this a Django bug? Something you've seen before?
As AMO is using server-side caching, it may be possible to exploit this issue for defacement using cache-poisoning. I don't think I could safely test this though. I've investigated the logic a little. The example configuration described for Apache at https://docs.djangoproject.com/en/1.4/topics/security/#host-headers-and-virtual-hosting and the ?nginx? config used by Mozilla both have the same issue; they fail to enforce 'It always validates incoming HTTP Host headers against the expected host name.' Instead, they validate the ServerName/server_name variable, which is only set by the host header if a host isn't specified in the first line of the request. I think the best solution would probably be for Django to use the ServerName value if it's present. Alternatively/as a short team solution, you could modify the server config to validate the actual host header.
I've notified security@djangoproject.com, and they're probably going to fix it with a whitelist of trusted hosts approach. This ought to prevent any recurrences.
Flags: sec-bounty? → sec-bounty+
It appears that AMO has *.mozilla.org whitelisted. Given the number of sites and servers this contains, it might be safer to lock it down a tad more - every https resource loaded by the 404 page of every server (on every port) could get the key in the referer header. Not a huge risk, but not ideal.
Next actions on this bug are to review why we have *.mozilla.org whitelisted and if we could make it something more like *.a.m.o or even a.m.o. After that we either change it or wontfix it knowing the risk.
(In reply to Wil Clouser [:clouserw] from comment #6) > Next actions on this bug are to review why we have *.mozilla.org whitelisted > and if we could make it something more like *.a.m.o or even a.m.o. After > that we either change it or wontfix it knowing the risk. There's no specific reason for *.mozilla.org, just that when we pushed out this fix getting the list of domains that was needed on prod was hard to figure out and it doesn't match stage or dev. Recommend caution on this push since you can't test it.
Either *.a.m.o and a.m.o sounds fine to me. I spent a while looking for ways to exploit the current wildcard and made a semi-functional exploit using a malicious attachment at bugXXXXX.bugzilla.mozilla.org. It required that the target first click the poisoned email link (which would redirect them to https://bugzilla.mozilla.org/show_bug.cgi?id=XXXXXX), and then click 'view attachment' - I never quite managed to get it down to a single click.
Retested - nginx is properly responding now, closing bug. Request: POST https://addons.mozilla.org/en-US/firefox/users/pwreset HTTP/1.1 Host: evil.com (snip) csrfmiddlewaretoken=XXXXXXXXXXXXXXX&email=amuntner%40mozilla.com Response: HTTP/1.1 502 Bad Gateway Server: nginx Date: Thu, 24 Sep 2015 11:06:54 GMT Content-Type: text/html; charset=utf-8 Content-Length: 166 Connection: close <html> <head><title>502 Bad Gateway</title></head> <body bgcolor="white"> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html>
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
(various other permutations of the malicious input returned the same result)
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.