JSON hijacking
Browsers (Edge, Chrome, Safari) allowed cross-domain reading of undefined JavaScript variables via prototype pollution with a Proxy, and by using exotic charsets like UTF-16BE, attackers could steal JSON data and bypass CSP. An attacker could read sensitive data from other domains and execute scripts despite CSP.
blog.portswigger.net
Published on blog.portswigger.net
I presented this topic at OWASP London and Manchester. You can find the talk and slides below:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely browsers did not properly isolate JavaScript prototypes across domains and allowed script charset attributes to reinterpret non-JavaScript content as executable code.
Impact
An attacker could steal sensitive data from other domains and bypass CSP, but the attack is limited by the need for specific characters to form valid JavaScript variables and was patched in some browsers.
What the attacker needed
Victim visits malicious page; browser vulnerable to prototype pollution; control over part of JSON response (for some attacks)
The fix
The issue was fixed in Chrome 54 and later patched in other browsers; mitigation includes declaring charset in HTTP Content-Type header.
How it was found
- Set the prototype of __proto__ to a Proxy with a 'has' trap that alerts the property name.
- Include a cross-domain script that contains an undefined variable.
- Observe the alert revealing the variable name.
- For JSON feeds, use a script tag with charset UTF-16BE pointing to a JSON response.
- Inject characters to make the JSON parse as a valid JavaScript variable.
- The Proxy trap captures the variable name containing the JSON data.
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 write-up has not been written yet. The Original tab links to the source.
This report shows how a malicious website could read data from another website that a user is logged into. The trick involves making the browser treat data as code and using special text encodings to hide the theft. It means private information like your messages or account details could be stolen just by visiting a bad page.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.