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.
Groups prefer hosted packages
Section titled “Groups prefer hosted packages”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 ✗ ignoredSet group.preferHosted: false only if you deliberately mix internal and
public versions of the same name.
Routing rules
Section titled “Routing rules”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 |
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 decidescurl -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).
resource "entrepot_routing_rule" "no_internal_names" { name = "no-internal-names" mode = "block" matchers = ["^@acme/", "^acme-"]}
resource "entrepot_repository" "npm_proxy" { name = "npm-proxy" format = "npm" kind = "proxy" blob_store = "default" proxy = { remote_url = "https://registry.npmjs.org" routing_rule = entrepot_routing_rule.no_internal_names.name }}- Blocked requests look like
404to 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-lists
Section titled “Allow-lists”allow rules turn a proxy into a curated mirror — for example only the
official images from Docker Hub:
curl -fsS -H "Authorization: Bearer $ADMIN" -X POST $E/api/v1/routing-rules -d '{ "name": "official-images-only", "mode": "allow", "matchers": ["^library/"]}'Checklist
Section titled “Checklist”- Install from groups, never directly from proxies.
- Keep
preferHostedon and the hosted repository a member of the group. - Add a block rule for every internal namespace (
^@acme/,^acme-,^acme\.) on every proxy of that ecosystem. - Register your npm scopes (
@acme) on npmjs.com even if you never publish there — owning the scope is the strongest protection. - Pin versions and commit lockfiles; review lockfile diffs that change the resolved registry.