XS-Leaks with CSP (base-uri) bypass by img tag.
A page's Content-Security-Policy blocked injection of a base tag, but Firefox still resolved relative image URLs against the injected base element, so requests went to an attacker-controlled host. An attacker who can inject HTML could therefore leak a secret path or identifier embedded in an image URL through cross-site leaks.
Originally disclosed on Mozilla
- Fixed in 3 months
- Paid in 21 months
- Disclosed after 3 months
Created attachment 9277231
Information leaks to attack.example.com
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0
Steps to reproduce:
I have a Content-Security-Policy that restricts reading of the base tag to 'self'.
And checked if this restriction is effective by injecting HTML tags.
Actual results:
CSP appeared to have successfully prevented base tag injection.
However, from the img tag, it was confirmed that the request was sent to the URI specified in the base.
Only FireFox could get the secret path of a user's img tag by XS-Leaks.
The attached poc.html confirms the leakage of confidential information (uuid).
I am assuming an attack scenario where the profile URL is secret and the tag injection occurs on the top page.
Expected results:
A base tag blocked by CSP is invalid, and the img tag should issue a request to the original URI.
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 the browser applied the CSP base-uri restriction to the base element itself but still used the injected base URL when resolving relative image sources.
Impact
An attacker able to inject HTML could leak a secret path or identifier from a user's image URL, but only in Firefox.
What the attacker needed
HTML injection on the top page; Victim uses Firefox; Profile URL is secret
How it was found
- Set a Content-Security-Policy that restricts the base tag to 'self'.
- Inject HTML tags to check whether the base tag restriction holds.
- Observe that the base tag injection appears to be blocked.
- Inject an img tag and see that the request goes to the URI from the base element.
- Use the attached proof of concept to confirm a secret uuid leaks.
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.
A base tag tells the browser where relative links and images should be loaded from. The site tried to stop attackers adding one by using a security policy, and most checks said it worked. But in Firefox, images still followed the injected base, so the browser quietly sent a request to the attacker's server, revealing a secret value in the image address.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.