“Package Hijack Meets GraphQL Goldmine: How One Recon Session
A staging GraphQL endpoint exposed an npm package token field, allowing unauthenticated extraction of hundreds of developer tokens. One leaked token gave write access to a public npm package, enabling a malicious update that could execute code on systems pulling the dependency.
Free link 🎈
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 GraphQL schema exposed a sensitive npm token field without authentication, and the leaked token had publish rights to a public package.
Impact
The attacker could run arbitrary code on production servers and CI/CD pipelines, and obtained full developer email and token exposure.
What the attacker needed
Access to the staging GraphQL endpoint; no authentication required; a leaked npm token with publish rights
The fix
The GraphQL schema should not expose sensitive token fields, and npm tokens should be scoped to least privilege and rotated.
How it was found
- Perform subdomain enumeration and HTTP probing to find live hosts.
- Use a URL discovery tool to find GraphQL endpoints.
- Send an introspection query to the staging GraphQL endpoint.
- Query the allUsers field to extract email addresses and npmPackageToken values.
- Validate a leaked npm token with a ping command.
- Publish a malicious update to the public package using the leaked token.
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 GraphQL endpoint is a way for apps to ask for data. Here, it was left open on a staging server and revealed a secret field containing npm tokens. Those tokens let someone publish a malicious update to a software package, which could run harmful code on any computer that installed it.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.