Your internal package `acme-utils` exists in a private registry. How do you prevent dependency confusion?
AdvancedScenarioSupply Chain Security
Answer
Situation read → If the package manager checks a public registry too, an attacker can publish acme-utils with a higher version and win resolution.
What I'd do →
- Use scoped or namespaced names: npm
@acme/utils; register the scope publicly as well. - Configure the client to route the scope to the private registry:
@acme:registry=https://npm.acme.internal/. - In pip, avoid
--extra-index-url; use a single proxy index with exclusion rules. - In Maven/Gradle, use repository content filtering for the group.
- Use lockfiles with hashes and block resolution of internal names from public upstream in Artifactory or Nexus.
Why → Namespace ownership and a single resolution path remove the ambiguity.
Interview tip → Cite Alex Birsan's 2021 research as the origin.
More on Supply Chain Security
What is an SBOM, and at which point in the pipeline do you generate it?BeginnerA customer asks for an SBOM for your product. What do you give them?BeginnerHow do you sign container images in GitHub Actions without managing private keys?IntermediateYou signed images in CI. How do you make sure the cluster only runs signed images?IntermediateLeadership wants "SLSA compliance". What do you propose?IntermediateWhat is typosquatting and how do you protect developers from it?Beginner