How I managed to trigger a Stored-XSS in an online store with the help of Cache Poisoning
A staff subdomain reflected an extra Host header and a cookie value in its responses, and a POST parameter was stored by the caching server and reflected on the page. By submitting a string followed by a script tag, the author got stored script execution through the poisoned cache.
Today I will be writing about how I was able to trigger an sXSS with the help of web-cache poisoning attack.
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 reflected user-controlled input (Host header, cookie, POST parameter) without validation or encoding, and the caching layer stored the response containing that input.
Impact
An attacker could poison the shared cache so other visitors, including staff, received a page that ran the attacker's script in their browser.
What the attacker needed
Access to the staff subdomain; ability to send crafted requests; victim loads the poisoned page
The fix
Input should be validated and output encoded, and the cache should not store responses that reflect user-controlled headers or parameters.
How it was found
- Enumerate subdomains and find the staff subdomain with an admin login panel.
- Notice that an extra Host header is reflected in the response source.
- Find that a cookie parameter value is also reflected in the response.
- Send a POST request with a parameter value and observe it is saved by the caching server.
- Submit a string followed by a script tag as the parameter value and load the page to see it execute.
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.
A web cache is a shared copy of a page kept by a server so it can be served faster to everyone. If an attacker can make the server save a page containing their own script, every visitor who gets that cached copy runs the script in their browser. That is called stored cross-site scripting delivered through cache poisoning.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.