Web cache poisoning
A series of PortSwigger labs show that the web cache keys requests without certain headers, cookies, query strings or parameters, so a response containing attacker-controlled script can be stored and served to other visitors. An attacker could poison the cache so that a victim's browser runs the injected JavaScript.
medium.com
Published on medium.com
Lab-1: Web cache poisoning with an unkeyed header
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 cache key omits inputs (headers, cookies, query strings or parameters) that the back-end reflects into the response, so poisoned responses are reused for other users.
Impact
A victim visiting the poisoned page could have attacker-supplied JavaScript executed in their browser, though the labs rely on a short cache lifetime and a victim who visits the home page.
What the attacker needed
A cacheable endpoint; an unkeyed input reflected in the response; victim visits the poisoned page
How it was found
- Find that the site uses a cache and identify which inputs are reflected in the response.
- Confirm the input is unkeyed by removing it and seeing the poisoned response still served.
- Build an exploit server hosting a malicious script.
- Send the crafted request so the response is cached.
- Load the poisoned URL and confirm the script executes.
- Wait for the victim to visit the endpoint and the lab is solved.
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 server that stores copies of pages so it can answer the next visitor faster. If the cache decides which copy to reuse without looking at some part of the request (a header, cookie or parameter), an attacker can slip malicious content into the stored copy. Every later visitor then receives the attacker's page, and any script in it runs in their browser.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.