Scream at it until it Escalates - XSS to ATO via Server Size Errors Gadgets
The report describes how server URL and header size limits (414 and 431 status codes) can be abused to break redirect chains that pass session tokens in URLs, allowing an attacker with XSS to steal the token and take over accounts. It demonstrates two scenarios: one using a 414 error to break a Salesforce redirect chain, and another using a 431 error to break a Flask redirect chain.
castilho.sh
Published on castilho.sh
Servers, like humans, have limits on how much data they can handle at once. Maybe you're familiar with the 414 and 431 status codes:
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 application passes session tokens in URL query parameters during redirects, and server size limits can be triggered to break the redirect chain, exposing the token to the attacker.
What the attacker needed
XSS vulnerability on the target site; Server with URL or header size limits; Session token passed in URL during redirect
The fix
The recommended fix is to add a WAF rule that redirects overly long URLs to the root page instead of returning an error, and to maintain a strict allowlist of permitted paths in URL parameters.
How it was found
- The attacker identifies an XSS vulnerability on a site that uses redirects with session tokens in the URL.
- For the 414 scenario, the attacker crafts a URL with a long 'url' parameter just below the server's limit.
- When the redirect occurs, the added token makes the URL exceed the limit, causing a 414 error and breaking the chain.
- The attacker's script reads the token from the error page's URL and sends it to their server.
- For the 431 scenario, the attacker sets large cookies to exceed the header size limit.
- The attacker makes a request to a redirect endpoint, causing a 431 error and exposing the token in the URL.
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.
When a website redirects you to another page, it sometimes puts a secret token in the web address. If an attacker can run their own code on the page (an XSS attack), they can make the web address very long so the server refuses to process it and stops the redirect. Then the attacker can read the secret token from the address and use it to log in as the victim.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.