How I Discovered a Live Dependency Confusion Vulnerability in a G
A GraphQL endpoint exposed internal package names through introspection, and one private package was missing from the public npm registry. The researcher published a higher-versioned package with the same name, and the internal build system fetched and executed it, causing an out-of-band callback.
Published on sanaullahamankorai.medium.com
In this write-up, I will walk you through how I discovered a live Dependency Confusion vulnerability using GraphQL introspection and validated the possibility of internal package resolution — all without revealing the target or module names for privacy and responsible disclosure.
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 build system resolved scoped packages from the public npm registry before or instead of the private registry, and the internal package name was not reserved publicly.
Impact
The injected postinstall script was executed by the internal build system, giving remote code execution that could leak environment variables, compromise CI/CD secrets, and pivot into internal networks.
What the attacker needed
GraphQL introspection enabled; Internal package name absent from public registry; Build system resolves from public registry; Ability to publish to public npm
The fix
Private packages should be scoped to an internal registry, the package manager should be configured to use that registry for the company scope, and CI/CD should allow-list expected packages.
How it was found
- Query the GraphQL endpoint with an introspection query to reveal internal schema fields.
- Read the response to obtain internal package names and versions.
- Check the public npm registry for one internal package name and find it missing.
- Publish a package with the same name and a higher version containing a postinstall script that calls an out-of-band listener.
- Monitor the out-of-band platform for a callback from the build system.
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.
Dependency confusion is when a company uses a private package name that is not registered publicly. An attacker can register that same name on the public registry with a higher version, and if the build system checks the public registry first, it downloads and runs the attacker's code. Here, the researcher found internal package names by asking a GraphQL API to describe itself, then proved the build system would fetch a fake public package.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.