Threat Alert: Private npm Packages Disclosed via Timing Attacks
The npm API responds more slowly when queried for an existing private package than for a non-existent one, allowing an unauthenticated attacker to determine whether a private package exists. An attacker could then create a public package with the same name to trick developers into installing malicious code.
Published on blog.aquasec.com
Yakir KadkodaIlay Goldman
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 a caching mechanism in npm's API causes different response times for existing versus non-existing private packages.
Impact
An attacker could discover private package names and then publish malicious public packages with the same names, potentially leading to supply chain attacks; GitHub stated that architectural limitations prevent them from systematically preventing such timing attacks.
What the attacker needed
No authentication needed; network access to npm API; ability to measure response times
The fix
GitHub declined to fix it, stating that architectural nuances prevent them from systematically preventing timing attacks; mitigation includes creating public placeholder packages and monitoring for typo-squatting.
How it was found
- Create a private npm package under an organisation scope.
- Send about five consecutive unauthenticated API requests for that private package and measure the average response time.
- Send about five consecutive unauthenticated API requests for a non-existent private package and measure the average response time.
- Compare the average times: existing packages take longer (e.g., 648 ms vs 101 ms).
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 you ask npm's registry for a private package, it always says 'not found', but it takes longer to answer if the package actually exists. By measuring these small time differences, an attacker can guess which private package names are real. They can then publish a fake public package with the same name, hoping someone installs it by mistake.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.