FlawOpen

flawopen.com/Reference/Dependency Confusion

Dependency Confusion: How Package-Source Mix-ups Happen

High Severity CWE-829: Inclusion of Functionality from Untrusted Control Sphere Software Supply Chain
ELI5 — The look-alike supplier

Imagine your team orders a component from a supplier catalog, but two suppliers use the same product name. If the ordering rules do not identify which supplier is authoritative, the build may receive an unintended component. Dependency confusion is this source-selection failure in software packages: a build resolves a package name from a registry or namespace the organization did not intend to trust.

Boundary: Package name, namespace, registry configuration, and lockfile provenance
Failure: The resolver can obtain a same-name package from an unintended source
Impact: Unreviewed third-party code may enter builds; installation scripts can run when enabled
Remediation: Explicit namespace-to-registry policy, reviewed lockfiles, and least-privilege builds

How dependency confusion happens

The exact behavior depends on the package manager and its configuration. A concrete case is pip: its documentation warns that combining a private --index-url with public --extra-index-url can allow a same-name public package to be selected. npm instead chooses a registry based on package scope or its configured default; it does not universally compare a private and public version and pick the larger one. The common root cause is ambiguous source policy: a build can resolve a dependency name from a source outside the organization’s intended trust boundary. If the resolved package is installed and its lifecycle/build scripts are enabled, those scripts execute in the build environment with that job’s available permissions.

pip.conf and requirements.txt (ambiguous sources)Risky configuration
[global]
index-url = https://packages.example.internal/simple
extra-index-url = https://pypi.org/simple

corp-auth-utils
.npmrc and package.json (explicit scope routing)Hardened example
@corp:registry=https://packages.example.internal/repository/npm/

{
  "dependencies": {
    "@corp/billing-engine": "1.2.0"
  }
}

A dependency-confusion failure path

Defensive engineering controls

Explore related security topics and incident analyses:Security directory →

References

See also Docker Socket Exposure: Risks and Defenses GitHub Actions Script Injection: Safe Workflow Inputs Cosign GHSA-fx35-mq7g-6g98: Bundle Verification Bypass