Skip to content

Dependency confusion

Dependency confusion is when an attacker publishes a public package with the same name as one of your internal packages and a higher version, so that builds resolving through a group pick up the public one. Entrepot has two defences. Use both.

For npm, PyPI and Helm groups, if any hosted member has a package name, proxy members never contribute versions or files for that name — no matter how high the public version is. This is on by default (group.preferHosted: true) and applies through nested groups too.

npm-group (preferHosted)
├── npm-internal (hosted) @acme/widgets 1.4.0 ◄── only source for @acme/widgets
└── npm-proxy (proxy) @acme/widgets 99.0.0 ✗ ignored

Set group.preferHosted: false only if you deliberately mix internal and public versions of the same name.

A routing rule restricts what a proxy may fetch from its upstream. It has a mode and a list of regular expressions:

  • block — matching requests never go upstream;
  • allow — only matching requests go upstream.

Rules are matched against a format-aware subject:

Format Subject
npm package name (@acme/widgets)
PyPI normalised project name (acme-utils)
Docker upstream image name (library/alpine)
Helm chart name; blocked charts are also filtered out of the proxied index.yaml
others the request path
Terminal window
curl -fsS -H "Authorization: Bearer $ADMIN" -X POST $E/api/v1/routing-rules -d '{
"name": "no-internal-names", "mode": "block", "matchers": ["^@acme/", "^acme-"],
"description": "Internal namespaces are never fetched from public registries"
}'
# check what the rule decides
curl -fsS -H "Authorization: Bearer $ADMIN" -X POST $E/api/v1/routing-rules/no-internal-names/test \
-d '{"path":"@acme/widgets"}'
# → {"allowed": false, "matched": "^@acme/"}

Then attach it to the proxies ("proxy": {"routingRule": "no-internal-names", …} on npm-proxy and pypi-proxy).

  • Blocked requests look like 404 to clients.
  • A rule that a proxy uses can’t be deleted (409).
  • Content cached before a rule was added keeps being served until it goes stale.

allow rules turn a proxy into a curated mirror — for example only the official images from Docker Hub:

Terminal window
curl -fsS -H "Authorization: Bearer $ADMIN" -X POST $E/api/v1/routing-rules -d '{
"name": "official-images-only", "mode": "allow", "matchers": ["^library/"]
}'
  1. Install from groups, never directly from proxies.
  2. Keep preferHosted on and the hosted repository a member of the group.
  3. Add a block rule for every internal namespace (^@acme/, ^acme-, ^acme\.) on every proxy of that ecosystem.
  4. Register your npm scopes (@acme) on npmjs.com even if you never publish there — owning the scope is the strongest protection.
  5. Pin versions and commit lockfiles; review lockfile diffs that change the resolved registry.