dependency-confusion
Supply-chain testing via package-manager dependency confusion: when internal package names resolve to attacker-controlled public registries, leading to malicious install and script execution. Use for npm/pip/gem/Maven/Composer/Docker manifest review and authorized red-team supply-chain exercises.
Security Assessment
Detected risks:
About dependency-confusion
A supply-chain security playbook covering package-manager dependency confusion, where an internal package name also exists — or can be squatted — on a public registry. When a resolver can see both private and public indexes and version ranges allow it, a public release with a higher semver can win resolution, and the package manager's lifecycle scripts then execute attacker-controlled code on developer laptops, CI runners, or production image builds. Impact tends to be broad across many consumers and silent until a build or runtime hook fires.
It breaks down the confusion angle for each ecosystem — npm (scoped versus unscoped names and .npmrc registry mapping), pip (--extra-index-url merging indexes), RubyGems (source order), Maven (repository declaration order and mirrors), Composer (Packagist collisions), and Docker (image typosquatting). Reconnaissance guidance shows where internal names leak (committed manifests, JavaScript source maps, .npmrc and .pypirc, CI logs, and SBOM exports) and gives read-only claimability probes such as npm view, pip install --dry-run, and gem search --remote.
For authorized engagements it describes a non-destructive proof-of-concept pattern: register the name, publish a higher semver within the victim's declared range, and add a preinstall/postinstall or setup hook that makes a DNS/HTTP callback to a collaborator you control, avoiding data exfiltration or destructive writes. It references tooling (confused and DepFuzzer) and defensive controls — owned scoped packages with correct .npmrc mapping, exact version pinning with enforced lockfiles, avoiding careless --extra-index-url, and controlling repository order. Testing is restricted to systems and programs you are authorized to test.
FAQ
How does a dependency confusion attack work?
An internal package name is also published on a public registry with a higher semver; if the resolver sees both indexes and version ranges allow it, the public package wins and its install lifecycle scripts execute attacker code.
Which ecosystems are covered?
npm, pip, RubyGems, Maven, Composer, and Docker, each with its own confusion angle such as npm scopes, pip --extra-index-url merging, and Maven repository declaration order.
How do you check whether a name is claimable without attacking?
Read-only probes like npm view <name> version, pip install --dry-run '<name>==99.99.99', and gem search '^name$' --remote, which are treated as passive recon.
What proof-of-concept pattern does it recommend?
Non-destructive callbacks: a preinstall/postinstall or setup.py install hook that makes a DNS or HTTP request to a collaborator you control, with no destructive writes and no data exfiltration.
What defenses does it list?
Organization-owned scoped packages with correct .npmrc mapping, exact-version pinning with enforced lockfiles, avoiding careless --extra-index-url, and controlling repository and mirror order.
Install dependency-confusion
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
yaklang/hack-skills