Join our Newsletter — 33% off our NHI Course

Repository Confusion

A repository confusion attack happens when tooling treats code or commits from a fork, mirror, or other untrusted source as if they belonged to the trusted upstream project. The risk is that package installs, CI jobs, or automation can execute attacker controlled code while appearing to reference a legitimate repository.

Expanded Definition

Repository confusion is a supply chain trust failure that appears when systems cannot reliably distinguish the canonical upstream repository from a fork, mirror, or other lookalike source. In practice, the danger is not just malicious code, but mistaken trust: automation, package tooling, or CI pipelines may grant the same authority to untrusted content that they would normally reserve for the original project. This makes repository identity a security boundary, especially where build steps can fetch dependencies, run tests, or publish artifacts without human review.

The concept sits close to source integrity, but it is broader than code signing alone. A signed commit or tagged release can still be misused if workflows resolve the wrong repository location, branch, or namespace. For that reason, teams should treat provenance, origin verification, and repository allowlisting as separate checks, not as interchangeable safeguards. The terminology is still evolving across vendors and open source platforms, so NHI Management Group recommends defining the trusted source explicitly in policy rather than assuming the platform default is sufficient.

Authoritative control mapping can be grounded in NIST SP 800-53 Rev 5 Security and Privacy Controls, especially where configuration control and integrity verification are expected.

The most common misapplication is assuming a familiar repository name guarantees trust, which occurs when automation accepts forks or mirrors without validating the source namespace and commit provenance.

Examples and Use Cases

Implementing protections against repository confusion rigorously often introduces friction in developer workflows, requiring organisations to weigh fast automation against stricter source validation.

  • A CI pipeline pulls build instructions from a forked repository because the fork name matches the upstream project, causing unreviewed changes to run under trusted automation.
  • A package installer resolves dependencies from a mirror that was intended for resilience, but the mirror is not pinned to the verified upstream source.
  • An internal release process copies commits from a partner-managed repository without checking whether the branch is authoritative, creating a gap between expected and actual code origin.
  • A GitHub Action or similar automation is configured to trigger on repository events, but the trust policy does not distinguish between upstream activity and fork activity, allowing attacker-controlled workflow execution.
  • A security review compares hashes after the fact, but the earlier mistake was source selection, not artifact validation, so the wrong repository was trusted from the start.

Open source guidance from the OWASP Top 10 is useful when teams want to think about dependency trust, but repository confusion is specifically about selecting the right source before build or install actions begin.

Why It Matters for Security Teams

Repository confusion matters because it turns ordinary automation into an execution path for untrusted code. Once a pipeline, bot, or build service mistakes a fork or mirror for the upstream project, the resulting blast radius can include code execution, package publication, secret exposure, and poisoned release artifacts. Security teams need to understand that this is not just a developer convenience issue; it is a trust-boundary failure that affects software supply chain integrity and, in modern environments, the identities of machines and agents that perform the work.

This becomes especially relevant where non-human identities authenticate to source control, artifact registries, or CI systems. If those identities are broadly scoped or lack repository-level constraints, an attacker may be able to convert a naming mistake into an operational compromise. Controls from NIST SP 800-53 Rev 5 Security and Privacy Controls and source provenance practices should be paired with explicit repository allowlists, branch protections, and review gates.

Organisations typically encounter the consequence only after a pipeline has already executed attacker-controlled code, at which point repository confusion becomes operationally unavoidable to investigate and contain.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5 and NIST AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST CSF 2.0 PR.DS Repository confusion is a data and software integrity failure in the supply chain.
NIST SP 800-53 Rev 5 CM-8 Asset and configuration control help distinguish trusted repositories from lookalikes.
OWASP Non-Human Identity Top 10 NHI guidance applies when automation identities access repositories and artifacts.
NIST AI RMF AI RMF matters when agents or AI tools can fetch code from repositories.

Scope machine identities to specific repositories and validate source provenance at access time.