Wrong Handling of Content-Type allows Flash injection and Rosseta flash patch bypass
The Flash player searches for the string 'application/x-shockwave-flash' anywhere in the Content-Type header, so a response with that string in a parameter (e.g., lang) is treated as Flash even if the actual type is an image and nosniff is set. An attacker could upload a malicious Flash file disguised as an image and have it executed as Flash, bypassing the Rosetta Flash patch and enabling SOP bypass.
- Fixed in 6 months
- Paid in 6 months
- Disclosed after 4.3 years
Hey, I spent some time reversing the mitigation of Rosetta Flash. This research helped me to discover a very interesting bug:
Adobe Flash player uses "string searching" (similar to indexOf) over the entire response's "Content-Type" header value to match the "application/x-shockwave-flash" string. Once matched, the flash player will skip all checks/restrictions and render the file as a valid Flash file. Therefore responses which will include this string anywhere within the content header will allow the execution of various file types as flash applications (such files types may be images,videos,css,text files, and so on) - MIME Sniffing. This bug will also fully bypass an existing nosniff header: X-Content-Type-Options: nosniff.
Example vulnerable response header: Content-Type: text/plain; lang=application/x-shockwave-flash
Some web applications allow user data inside the content-type header. Such header injection can include "language" , "encoding type"(UTF-8,ISO.) etc or response splitting (vulnerable in Chrome).
There are two main case scenarios:
Classic MIME Sniffing - Rendering Images/text/media as Flash:
- The web application allows uploading an image file.
- Viewing the uploaded image is served through an Servlet that accepts encoding/language parameter.
- The attacker uploads a malicious flash file as an Image: "flashsniff.png"
- The attacker forge a malicious web page with the following payload
<object type="application/x-shockwave-flash" data="http://vulnerable-site.com/RenderImageServlet.php?imgId=1234&lang=application/x-shockwave-flash">
<param name="AllowScriptAccess" value="always"> </object>- The hosting server will respond with the following headers:
HTTP/1.1 200 OK .... X-Content-Type-Options: nosniff .... Content-Length: 733 Content-Type: image/png; charset=utf-8; lang=application/x-shockwave-flash
In this case Flash will execute malicious file types as flash applications even when X-Content-Type-Options: nosniff is on. PoC (Rendering Images as FLASH Files)
http://poc.benhayak.com/Flash/SniffingFlash.html Here I just present an alert as a PoC but this could've been a flash that will leak information via SOP bypass.
Rosetta Flash patch bypass using only alpha numeric flash: Brilliant Michele Spagnuolo made an amazing research and discovered the possibility to make execute flash files using only alphanumeric charset via jsonp endpoints: https://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
A mitigation was implemented to avoid this risk by:
- If content-type is application/x-shockwave-flash, execute the flash. (string search!)
- Verify there's at least 1 non alphanumeric character which is not a valid UTF-8 in the incoming string.
Since flash will ignore anything but the "application/x-shockwave-flash" value in the content-type string. using this bug will bypass the rosseta flash patch and allow executing Flash applications via jsonp endpoints once again!
PoC: (LOOK at the network panel for "attacker.com/crossdomain.xml" to see a SOP bypass via Michele's techinique)
http://poc.benhayak.com/Flash/rossetabypass.html
Regards, Ben Hayak
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute a malicious Flash file uploaded as an image, bypassing nosniff and the Rosetta Flash patch, potentially leading to SOP bypass and information leakage.
What the attacker needed
Victim visits attacker page; attacker can upload a file; server reflects user input in Content-Type
The fix
Applications should avoid putting user-controlled data into the Content-Type header.
How it was found
- The web application allows uploading an image file.
- Viewing the uploaded image is served through an Servlet that accepts encoding/language parameter.
- The attacker uploads a malicious flash file as an Image: "flashsniff.png"
- The attacker forge a malicious web page with the following payload
- The hosting server will respond with the following headers:
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a browser loads a file, it looks at the Content-Type header to decide how to handle it. Flash player checks if the header contains a certain text anywhere, not just as the main type. So if a website puts user input into the header, an attacker can make Flash treat an image as a Flash file, which can then run code and bypass security rules.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.