Plain Text Reading by XSSI
A site returned a CSRF token as plain text, which is valid JavaScript if it starts with a letter. An attacker could use a Proxy object to detect the token when the script is loaded cross-origin, leaking it.
balpha.de
Published on balpha.de
The same origin policy prevents a website's JavaScript from seeing the result of a request made to a different domain. This is essential because that request would send along any cookies stored for that domain.
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 the endpoint returned a secret as plain text that could be syntactically valid JavaScript, allowing cross-origin script inclusion to execute it and leak the value via a Proxy trap.
Impact
The attacker could steal the CSRF token, but only if the token starts with a letter (37.5% chance) and the victim uses Firefox or Chrome with experimental JavaScript enabled.
What the attacker needed
Victim visits attacker's page; victim logged in to target site; token starts with a letter; Firefox or Chrome with experimental JS
The fix
The site should wrap the token in a JSON object (not an array), respond only to POST requests, or prepend a while(1) loop to prevent execution.
How it was found
- The attacker creates a page that sets a Proxy on the global object's prototype to watch for property lookups.
- The page then adds a script element pointing to the victim site's token endpoint.
- When the script loads, the browser executes the token as an identifier, triggering the Proxy's has trap.
- The trap checks if the name matches the token pattern and alerts the token if it does.
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.
Websites use a secret token to stop other sites from making requests on your behalf. This site sent that token as plain text, and browsers will run any text as code if it looks like a variable name. An attacker's page could load that text as a script and use a special JavaScript feature to read the token.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.