Use secretless runtime design so package installs never receive long-lived agent secrets, and bind access through short-lived workload identity, scoped tokens, or brokered retrieval at runtime. Package managers, build hooks, and install scripts should run with no direct access to API keys, certificates, or bearer tokens, because dependency code is a common exposure path for agent credentials.
Why package installs should not be able to read agent credentials
The failure mode is straightforward: install-time code is an untrusted execution path, and any secret available to that path can be copied, exfiltrated, or reused outside the original runtime. The safest design is to ensure package managers, build hooks, and post-install scripts never see long-lived secrets at all, only short-lived, tightly scoped access at the moment it is needed.
That is why secretless runtime design matters more than “better storage” alone. If the install process can reach API keys, certificates, or bearer tokens, the blast radius is the credential itself, not just the package you intended to install.
For a broader pattern of moving from static secrets to ephemeral access, Ultimate Guide to NHIs, Static vs Dynamic Secrets is the clearest place to anchor the design choice, because it explains why long-lived credentials create unnecessary exposure.
What controls actually break the exposure path
The practical control is to separate installation from authorization. Package installs should inherit no ambient secret context, and any runtime access should be brokered through a short-lived token, workload identity, or credential exchange that is valid only for the exact action being performed.
That usually means three things: keep secrets out of environment variables and config files used by install logic, avoid embedding keys in build images or developer workstations, and scope tokens so a dependency cannot mint broader access than it needs. If a package only needs to fetch one artifact or call one internal endpoint, do not hand it a reusable credential that can touch everything else.
Secrets Management Guide is useful here because it ties together secretless design, dynamic secrets, and the operational shift away from long-lived credentials.
Credential Vaulting for AI Agents Guide also maps cleanly to this problem, since the same brokered retrieval pattern applies when runtime code needs ephemeral access without direct secret exposure.
What to do when package installation still needs privileged access
Sometimes an installer truly needs network or registry access to complete, but that should not mean it receives a reusable secret. The better pattern is a narrow, brokered grant that is constrained by audience, scope, and lifetime, with no direct read access to the underlying secret material.
If you cannot remove all access immediately, the next-best containment is to isolate installation in a throwaway environment, revoke access immediately after install, and ensure the package process cannot persist credentials into logs, caches, lockfiles, or telemetry. The key question is not whether the package “normally” behaves, but whether a malicious or compromised dependency could observe a credential during its own install path.
The exposure risk is especially clear in dependency ecosystems, where install scripts, transitive packages, and prebuild steps may run before your application has any chance to constrain behavior. That is why package supply chain hygiene and secret handling need to be treated as one problem, not two separate ones.
LiteLLM PyPI package breach is a concrete reminder that dependency execution can become a credential exposure path, even when the compromise begins as a software distribution issue.
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 and OWASP API Security Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | Package installs exposing credentials is secret leakage risk. |
| NHI-07 — Long-Lived Secrets | The answer centers on avoiding long-lived agent secrets in installs. | |
| NHI-05 — Overprivileged NHI | Install paths should not inherit broad credential scope or reuse. | |
| Recommendation — Eliminate secret exposure in install paths and move to short-lived runtime access. Replace static credentials with short-lived, brokered tokens and scoped access. Scope runtime access tightly and avoid reusable credentials in dependency execution. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Credential lifecycle and rotation are central to preventing exposure. |
| IA-9 — Service Identification and Authentication | Workload identity and brokered runtime access are the recommended pattern. | |
| Recommendation — Use ephemeral authenticators and revoke any credential exposed to install code. Authenticate workloads with short-lived service credentials instead of static secrets. | ||
| CIS Controls v8 | CIS-5 — Account Management | The issue is controlling access paths and removing standing credentials from installs. |
| Recommendation — Reduce standing access and remove credentials from package installation environments. | ||
| OWASP API Security Top 10 | API2 — Broken Authentication | Brokered token use and scoped access prevent weak credential handling in tool paths. |
| Recommendation — Use strong token handling and avoid exposing bearer secrets to untrusted install code. | ||
Practitioner Guidance
What to verify: Check whether install-time tooling can read any credential that is still valid after the install finishes. If the answer is yes, treat that as a design flaw, not just a hardening gap.
Decision rule: If a dependency only needs access during execution, give it a short-lived, brokered token at runtime; if it needs direct secret material during install, redesign the flow so the secret is never present in the install context.
Common mistake: Teams often rotate secrets after a leak but leave the same exposure path in place. That reduces immediate damage, but it does not fix the architecture that made package installs able to see the credential in the first place.
Practitioner takeaway: The durable fix is to remove secrets from the install path entirely, because any secret visible during dependency installation should be assumed exposed.
Related resources from NHI Mgmt Group
- Guide: Security Responsibilities for AI Engineers Guide
- When do AI agent credentials create more risk than they reduce?
- What is the difference between human identity governance and AI agent governance?
- When does AI agent access create more risk than it reduces?
- What is the difference between governing human access and governing AI agent access?
Deepen Your Knowledge
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.
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org