Import-time execution collapses the usual separation between dependency loading and code execution. Once the package runs on import, it can read environment variables, load companion payloads, and start secondary behaviour before most scanners or approval gates have any chance to intervene. The control failure is trusting package installation or import as a safe, passive step.
Why This Matters for Security Teams
When a dependency executes during import, the build pipeline stops behaving like a controlled assembly line and starts behaving like a runtime execution environment. That is a security problem because CI/CD jobs often carry broad access to source, secrets, signing material, package registries, and deployment targets. Once malicious code runs in the import path, it can observe the environment, exfiltrate credentials, or stage follow-on actions before most approval gates or scanners are invoked.
This risk is not theoretical. NHIMG’s CI/CD pipeline exploitation case study shows how quickly a trusted automation step can become a compromise bridge, and the Guide to the Secret Sprawl Challenge explains why pipelines remain attractive targets when secrets are overexposed. The issue is amplified by the fact that a single imported package can inherit more privilege than its authors ever intended. In practice, many security teams discover this only after a build token, signing key, or cloud credential has already been used, rather than through intentional pre-execution inspection.
How It Works in Practice
Import-time compromise works because package managers and language runtimes often treat installation and import as normal developer activity, not as privileged execution. In a Python, Node.js, or similar pipeline, a package can run code as soon as it is imported, which means the attacker does not need a separate “launch” step. The payload can read environment variables, inspect mounted files, fetch secondary stages, or alter build outputs while still appearing to be part of routine dependency resolution.
The right response is to assume the package may execute, then reduce what that execution can touch. Current guidance from the NIST Security and Privacy Controls supports least privilege, separation of duties, and monitoring, but those controls need to be applied to ephemeral build identities and to the secrets exposed at runtime. For supply chain cases like this, practitioners should combine:
- short-lived credentials for build jobs instead of long-lived secrets in environment variables
- restricted package provenance checks before install or import
- network egress limits so a compromised import cannot freely call out
- isolated runners with no access to signing keys unless the step explicitly needs them
- runtime logging that records unexpected subprocesses, file reads, and registry access
The LiteLLM PyPI package breach illustrates how quickly trust in a package can be weaponized, while the Reviewdog GitHub Action supply chain attack shows the blast radius when CI automation already has access to sensitive data. These controls tend to break down when build jobs inherit broad repository, cloud, or signing privileges because the import step then becomes a fully trusted execution point.
Common Variations and Edge Cases
Tighter package controls often increase friction for developers and release engineering, so organisations have to balance delivery speed against the blast radius of a compromised dependency. That tradeoff is real, especially in environments that rely on dynamic plugin systems, monorepos, or package hooks where import-time behaviour is expected.
There is no universal standard for how much logic is acceptable during import, but current guidance suggests treating any code that runs before the main entrypoint as untrusted runtime behaviour. In highly automated pipelines, that means using package allowlists, reproducible builds, and sandboxed dependency resolution rather than assuming a trusted installer. For broader identity and secrets context, NHIMG’s 52 NHI Breaches Analysis reinforces how often machine identities and automation tokens become the real target once execution is obtained.
The edge cases are the environments where “import” is actually a plugin bootstrap, test harness, or code-generation step. In those systems, the security boundary is not the repository checkout but the moment the runtime loads third-party code. That is why the safest default is to treat import as execution, not metadata, and to reserve any privileged secret only for the narrow step that truly needs it.
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, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-03 | Import-time execution often abuses exposed secrets and long-lived NHI credentials. |
| OWASP Agentic AI Top 10 | A-04 | Executed imports behave like untrusted autonomous code inside CI jobs. |
| CSA MAESTRO | M-08 | Supply chain execution in pipelines maps to agent/tool trust and runtime containment. |
| NIST AI RMF | The risk is contextual and dynamic, requiring runtime governance of AI-like autonomy. | |
| NIST CSF 2.0 | PR.AC-4 | Compromised imports exploit excessive access in CI/CD identities and secrets. |
Treat imported package code as runtime execution and gate it with least privilege and sandboxing.
Related resources from NHI Mgmt Group
- What breaks when an npm maintainer identity is compromised in a CI/CD pipeline?
- What breaks when CI/CD release workflows can be triggered by a compromised push credential?
- What breaks when a compromised package can run code during install or import?
- What breaks when CI/CD workflow actions or build credentials are tampered with?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org