The trust boundary around software installation breaks first. A package that executes during import can steal credentials before normal application controls load, which means endpoint scanning alone is too late. The practical response is to treat dependency execution as privileged code and block untrusted packages before they reach developer or build environments.
Why This Matters for Security Teams
A package that can execute during install or import turns dependency intake into an execution path, not just a delivery path. That matters because the first code to run may be the least trusted code in the stack, yet it can read environment variables, reach cloud metadata, or exfiltrate tokens before the application starts. NHI Mgmt Group has repeatedly shown that secrets exposure is already common in modern estates, including the Ultimate Guide to NHIs — Why NHI Security Matters Now, and that risk becomes more acute when install-time code runs with developer or build permissions.
Security teams often assume endpoint controls, package scanning, or post-install malware checks will catch the problem. They usually will not. By the time a malicious import hook or setup routine runs, the credential theft may already be complete, which is why this class of issue is treated as privileged code execution in supply chain guidance, not as a simple vulnerability management problem. Current practice also needs to account for the fact that modern software supply chain attacks increasingly target automation and identity material, as discussed in the Anthropic report on AI-orchestrated cyber espionage.
In practice, many security teams encounter credential theft only after build logs, cloud activity, or repository access show that the package already ran.
How It Works in Practice
The failure mode is straightforward: install-time hooks, import-time side effects, and transitive dependencies can execute before application policy, runtime guards, or human review steps have a chance to intervene. That is why the right control point is not only the host endpoint but also the package intake process. For high-risk environments, treat package execution as an identity and privilege event, then decide whether that code is allowed to run at all.
Practically, this means separating package acquisition from package execution. Teams should verify provenance, pin versions, and block packages that are not approved for developer workstations, CI runners, and build containers. Where possible, dependency execution should occur in sandboxed or ephemeral environments with no standing access to secrets. This aligns with the broader NHI governance pattern described in 52 NHI Breaches Analysis: reduce standing access, shorten credential lifetime, and assume that exposed secrets will be harvested quickly.
- Require signed or verified packages where the ecosystem supports it.
- Block install scripts and import-time execution unless explicitly approved.
- Use short-lived credentials for builds and revoke them after each job.
- Store secrets outside the environment by default, and inject only what the job truly needs.
- Run dependency resolution in isolated build workers with no direct access to production tokens.
For policy enforcement, current guidance suggests combining package allowlists with runtime controls defined in standards such as NIST SP 800-53 Rev. 5 Security and Privacy Controls, especially where software supply chain integrity and least privilege intersect. These controls tend to break down in CI/CD systems that reuse long-lived service account tokens across many builds, because a single malicious import can then reach far beyond the package manager itself.
Common Variations and Edge Cases
Tighter package controls often increase build friction, requiring organisations to balance developer velocity against the risk of arbitrary code execution during installation. That tradeoff is real, especially in fast-moving Python, JavaScript, and machine learning ecosystems where packages frequently run code on install or import.
There is no universal standard for this yet. Some ecosystems support stronger provenance checks and safer install patterns, while others rely on convention and community review. In highly regulated environments, best practice is evolving toward pre-approved internal mirrors, policy-as-code gates, and ephemeral build identities rather than trusting public registries directly. The LiteLLM PyPI incident is a useful reminder that package reputation alone is not a sufficient control, because a trusted dependency can still become a delivery mechanism for secret theft.
Edge cases matter most when developers run package installs on laptops that also hold browser sessions, cloud consoles, or SSH agents. In those environments, a malicious import can pivot into local credentials even if production systems are well segmented. That is why the operational answer is not just to scan for malware after download, but to deny execution by default and limit the secrets available to any dependency code that does run.
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-01 | Covers exposure of secrets and identities to untrusted execution paths. |
| OWASP Agentic AI Top 10 | A-05 | Untrusted code execution mirrors agent tool abuse and runtime abuse paths. |
| CSA MAESTRO | TR.3 | Addresses supply chain trust and execution control for autonomous workloads. |
| NIST AI RMF | Risk management must account for dynamic execution and identity exposure. | |
| NIST CSF 2.0 | PR.DS-6 | Supports integrity checks for software and dependency supply chains. |
Classify dependency execution as privileged code and deny access to secrets unless explicitly needed.
Related resources from NHI Mgmt Group
- What breaks when a compromised Python package can run code at interpreter startup?
- What breaks when malicious code can run inside a developer IDE or package install?
- What breaks when a trusted VS Code extension publisher is compromised?
- What breaks when malicious package installs are allowed to execute code by default?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org