How a Single Vulnerability Can Bring Down the JavaScript Ecosystem
The npm registry was vulnerable to cache poisoning denial of service: a request with a specific set of headers caused the backend to return a 'Not Found' response that was then cached, making a targeted package unavailable to other users. An attacker could repeatedly poison the cache to keep popular packages inaccessible, disrupting builds and installations.
Published on depi.security
In the world of software development, we often take for granted the security and reliability of the tools and platforms we rely on daily. We assume that the packages we download and the registries we use are safe and trustworthy.
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 caching layer stored error responses generated by malformed requests without validating that the request was legitimate, allowing an attacker to control what was cached for a given URL.
Impact
An attacker could make popular packages unavailable to other users, causing builds to fail and disrupting software development; the effect is temporary and requires repeated requests, and the attack affected only some backend servers.
What the attacker needed
Ability to send HTTP requests to the registry; knowledge of the header combination (not disclosed); repeated requests to maintain poisoning
The fix
GitHub said it would ship a fix, but the text does not confirm it was deployed; the fix should ensure error responses from malformed requests are not cached for legitimate URLs.
How it was found
- Send a request for a package file with a cache-busting parameter and a set of special headers that trigger an error.
- The backend returns a 'Not Found' response, which the cache stores under that URL.
- Send a second request without the special headers but with the same cache key.
- The cached 'Not Found' response is returned, making the package inaccessible.
- Repeat the poisoning periodically to maintain the effect, as the cache expires after a few minutes.
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 cache is a temporary storage that keeps copies of web responses to serve them faster. Cache poisoning means tricking that storage into keeping a wrong or harmful response, so later visitors get the bad copy instead of the real one. Here, a request with unusual headers made the server produce a 'not found' error, and that error got cached, so other people asking for the same package also received 'not found'.
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.