http redirect to data: inherits principal (SVG image cookie setting; object XSS)
Firefox allowed a redirect to a data: URI containing an SVG image to inherit the principal of the original domain, enabling the SVG to set cookies for that domain. An attacker could set arbitrary cookies for any domain that displays external images via the img tag.
Originally disclosed on Mozilla
- Fixed in 34 days
- Paid in 34 days
- Disclosed after 34 days
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
Steps to reproduce:
Tested on: Windows 7 x 64 Bit - Firefox 49.0.2 Tested on: Windows 8.1 x 32 Bit - Firefox Nightly: 53.0a1
A domain eg(example.com) loads an image file from an attacker controlled webserver: <img src="//attacker.com/redirect_svg.php">
The attacker server response with a redirect with an data: uri, which specifies an svg image file:
//redirect_svg.php HTTP 302 Found Location: data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%3E%3Ccircle%20r%3D%27100%27%3E %3C/circle%3E%3CforeignObject%3E%3Chtml%20xmlns%3D%27http%3A//www.w3.org/1999/xhtml%27%3E%3Cmeta%20http-equiv %3D%27Set-Cookie%27%20content%3D%27ppp%3Dqqq%27%20/%3E%3C/html%3E%3C/foreignObject%3E%3C/svg%3E
Decoded Payload: data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><circle r='100'></circle><foreignObject><html xmlns='http://www.w3.org/1999/xhtml'><meta http-equiv='Set-Cookie' content='ppp=qqq' /></html></foreignObject></svg>
The SVG file is interpreted and displayed on example.com and a cookie ppp=qqq is set for example.com
//Poc:
set DNS Host entry for attacker.com: 84.112.240.90
View: http://84.112.240.90/view_svg.html
Actual results:
Firefox detects and interprets the Set-Cookie value specified in the meta tag. This cookie is then stored for the domain example.com. This makes it possible to set arbitrary cookies for any domain, which supports external images from users, which are viewed via the img tag. As developers do not expect images to be able to set cookies for their own domain, this behavior can introduce security vulnerabilities.
Expected results:
Firefox should not interpret Set-Cookie values in SVG meta tags, as this is the behavior in other browsers.
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
Root cause
Likely, Firefox did not properly isolate the principal of a data: URI loaded via redirect from an img tag, allowing the SVG to inherit the original domain's origin and set cookies.
What the attacker needed
Victim domain displays external images; attacker controls image server; victim uses Firefox
The fix
Firefox should not interpret Set-Cookie values in SVG meta tags, as other browsers do not.
How it was found
- A domain loads an image from an attacker-controlled server via an img tag.
- The attacker server responds with a redirect to a data: URI containing an SVG image.
- The SVG image includes a meta tag that sets a cookie.
- Firefox interprets the SVG and sets the cookie for the original domain.
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 website shows an image from another server, the browser normally treats that image as untrusted. In this case, Firefox followed a redirect to a special image format that could run code and set cookies as if it came from the original website. This let an attacker set cookies for any site that displayed such an image.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.