Join our Newsletter — 33% off our NHI Course
Home› Glossary› Threats, Abuse & Incident Response› Phantom Dependency
Threats, Abuse & Incident Response

Phantom Dependency

← Back to Glossary
By NHI Mgmt Group Updated November 4, 2026 Domain: Threats, Abuse & Incident Response

A phantom dependency is a package added to a software supply chain for its side effects rather than for direct use by the application. It can remain invisible in normal code paths while still executing during installation, which makes package metadata and lifecycle scripts part of the attack surface.

What Phantom Dependencies Are

A phantom dependency is a package brought into a software supply chain for its side effects rather than for direct use by the application. It can stay hidden from normal code paths while still running during installation, which makes package metadata, installation behavior, and lifecycle scripts part of the trust boundary.

This matters because dependency review is often focused on imported code, while a phantom dependency may influence build-time or install-time behavior instead. In practice, the risk is not only what the application calls at runtime, but what the package executes before the application even starts.

How Phantom Dependencies Enter the Supply Chain

Phantom dependencies usually appear through ordinary package-manager workflows, transitive installs, or build tooling that executes package scripts automatically. That means the dependency may look routine in the manifest even when its real value lies in install hooks, postinstall actions, or other side effects that are easy to overlook in code review.

They are especially concerning in ecosystems where packages can execute code during installation or publish-time workflows can be abused. The issue is not limited to malicious packages, a legitimate dependency can become dangerous if its install-time behavior is broader than the application team expects.

  • They may be present for environment changes, not imported functions.
  • They can execute before application code has a chance to enforce its own controls.
  • They can be hidden in dependency trees that appear harmless at first glance.

Why Phantom Dependencies Are Dangerous

Side-effect-only packages expand the attack surface because trust shifts from application logic to package metadata and lifecycle behavior. A dependency that is never imported by the app can still alter files, run commands, fetch additional content, or influence the build environment.

That makes them a supply-chain concern rather than a pure code-quality issue. The practical danger is that security review may validate the wrong thing, such as source code usage, while missing install-time execution paths that actually determine impact. The OpenSSF ecosystem is a useful reference point for supply-chain hardening because it centres attention on the integrity of open source dependencies and the processes that consume them.

How Teams Reduce Exposure

Defending against phantom dependencies starts with knowing what is installed, how it arrived there, and whether package scripts or similar hooks are allowed to execute in your pipeline. Teams should treat package manifests, lockfiles, install-time behavior, and build tooling as first-class review objects, not just the source files imported by the application.

For broader control coverage, align dependency handling with supply-chain integrity practices and configuration hardening. Guidance on build provenance and secure dependency management is especially useful when you need to evaluate whether a package is present for a legitimate runtime purpose or only to trigger installation side effects. See SLSA for build provenance, and OWASP SAMM for integrating supply-chain checks into the software delivery process.

Risk and Threat Considerations

Phantom dependencies are risky because they hide execution in places teams often trust less than application code, such as installation hooks and package metadata. If an attacker can introduce or tamper with that dependency path, they may gain code execution during build or install time, before normal runtime controls are fully in place.

Failure mechanism: The package is accepted as a dependency even though its meaningful behavior happens during installation or other side-effectful lifecycle events, so review misses the real execution path.

Impact: The build environment, deployment pipeline, or packaged artifact can be altered without a corresponding application code change, creating a direct supply-chain compromise path.

Standards & Framework Alignment

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

SLSA, OWASP SAMM, CIS Controls v8, NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
SLSASupply-chain security and build provenancePhantom dependencies affect build provenance and artifact integrity.
Recommendation — Verify dependency provenance and restrict install-time execution in your build pipeline.
OWASP SAMMSoftware Assurance Maturity ModelSAMM covers secure software delivery practices where dependency review belongs.
Recommendation — Embed dependency review and build-time security checks into your delivery lifecycle.
CIS Controls v8CIS-16 — Application Software SecurityPhantom dependencies arise in software delivery and require secure dependency handling.
Recommendation — Harden software acquisition and deployment processes to control untrusted dependency behavior.
NIST CSF 2.0PR.DS-10 — Confidentiality, Integrity, and Availability of Data at Rest Is ProtectedSupply-chain manipulation of packages can alter software artifacts before use.
Recommendation — Protect software artifacts and package sources against tampering in the delivery chain.
NIST SP 800-53 Rev 5SA-15 — Development Process, Standards, and ToolsPhantom dependencies are a development-process and tooling concern during software delivery.
Recommendation — Use approved development tools and standards to govern package handling and install-time behavior.

Practitioner Guidance

What to watch for: Treat any package whose value depends on lifecycle scripts, install hooks, or build-time execution as higher scrutiny than a normal library dependency. The key question is whether the package is needed for application logic, or only because it changes the environment around the application.

Practitioner takeaway: If a dependency exists mainly for side effects, the control question is not “does the code import it?” but “what executes when the package is installed?”

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 4, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org