A malicious code path that runs as soon as a package is loaded with require() or import. Unlike an install hook, it does not wait for setup steps, so it can execute before a developer or CI job notices anything unusual. This makes dependency trust, egress control, and runtime monitoring essential.
Expanded Definition
Import-time payload refers to malicious logic embedded in a package so it executes the moment a module is loaded through import or require(). That timing matters because the payload runs before many application checks, setup steps, or review gates have a chance to detect abnormal behaviour. In supply-chain terms, this is a code-execution problem disguised as ordinary dependency resolution.
Unlike an install-time hook, an import-time payload does not depend on package installation scripts or explicit post-install actions. It can trigger during application startup, test execution, serverless cold starts, or any path that loads the dependency. Guidance is still evolving across ecosystems, but the security pattern is clear: the package boundary is not a trust boundary, and imports should be treated as executable actions with side effects.
NIST Cybersecurity Framework 2.0 helps frame this as a governance and monitoring issue, especially where software provenance, execution integrity, and runtime visibility are concerned, while OWASP’s supply-chain and dependency guidance reinforces the need to treat third-party code as potentially adversarial. The most common misapplication is assuming a dependency is safe because it passed installation checks, which occurs when teams do not inspect what runs at module load time.
Examples and Use Cases
Implementing import-time detection rigorously often introduces startup overhead and extra review work, requiring organisations to weigh developer convenience against the risk of silently executed code.
- A Node.js package executes a hidden routine on first require() that collects environment variables and sends them to an external endpoint.
- A Python dependency runs code inside its top-level module body during import, reaching out over the network before application logging is fully initialised.
- A build tool loads a transitive package during unit tests, and the import-time payload alters local files or inserts a backdoor into the test process.
- An internal service imports a recently updated library at startup, and the malicious path triggers only in production because that execution path is absent from basic smoke tests.
- Security teams compare the behaviour against package provenance and runtime controls, using references such as the NIST Cybersecurity Framework 2.0 and dependency-risk checks from platform guidance.
These cases are especially difficult when the payload is small, conditional, or disguised as legitimate initialisation logic. That is why import-time behaviour should be reviewed separately from installation scripts, and why runtime egress controls matter even for “trusted” internal packages.
Why It Matters for Security Teams
Security teams need to understand import-time payloads because they expose a gap between static trust and actual execution. A package can appear clean in source review or dependency approval and still perform harmful actions the moment it is loaded. That makes software composition analysis, package vetting, and runtime telemetry complementary rather than interchangeable.
This term matters directly to identity and secrets protection because import-time code often targets API keys, tokens, session data, and CI/CD credentials available in process memory or environment variables. It also intersects with NHI governance, since service accounts, automation tokens, and agent credentials are frequently present in the same execution context as imported libraries. In practice, teams need egress restrictions, least-privilege execution, and alerting that can distinguish normal module initialisation from suspicious outbound activity.
For broader governance, the term aligns with risk-based controls in NIST CSF and with modern secure-software expectations that emphasise provenance and monitoring over blind trust. Organisations typically encounter the damage only after an unexpected network connection, credential leak, or compromised build pipeline, at which point import-time payload becomes operationally unavoidable to address.
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 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | GV.SC | Defines supply-chain risk governance relevant to malicious dependency execution. |
| OWASP Non-Human Identity Top 10 | Covers NHI risks from exposed automation credentials and tokens in runtime contexts. | |
| NIST AI RMF | Applies where imported code supports AI pipelines that may inherit unsafe behaviour. |
Protect service tokens and automation identities from code that can read process context.
Related resources from NHI Mgmt Group
- How should teams choose between bulk import and just-in-time CIAM migration?
- What do security teams get wrong about import-time malware?
- Why do import-time payloads increase supply chain risk for NHI secrets?
- How should security teams detect delayed import-time droppers hidden in JavaScript packages?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org