Subscribe to the Non-Human & AI Identity Journal
Home FAQ Governance, Ownership & Risk Why do malicious packages so often target cloud…
Governance, Ownership & Risk

Why do malicious packages so often target cloud credentials and secrets?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated August 2, 2026 Domain: Governance, Ownership & Risk

Because installation steps often run in environments where secrets are already present. A malicious package can read environment variables, config files, or CI credentials and exfiltrate them without needing an exploit. That makes secret exposure a supply-chain issue as much as an application security issue.

Why This Matters for Security Teams

Malicious packages are effective because they do not need to break perimeter defenses if they can run where secrets already exist. Build servers, developer laptops, CI runners, and deployment jobs often carry cloud keys, API tokens, certificates, and session material in memory or on disk. Once a package executes during install or build time, it can enumerate those secrets and send them out before detection catches up.

This is not just an application security problem. It is also a secrets governance problem, a supply-chain trust problem, and in many environments a non-human identity problem, because the exposed material often belongs to automation, not a person. The most common mistake is assuming package risk stops at code quality, when the real exposure comes from the surrounding execution environment. NIST guidance on security controls in NIST SP 800-53 Rev 5 Security and Privacy Controls is useful here because it treats secrets handling, least privilege, and monitoring as operational controls rather than optional hardening.

In practice, many security teams encounter package-driven secret exposure only after cloud logs, billing anomalies, or credential abuse have already revealed the compromise, rather than through intentional detection of the installation event.

How It Works in Practice

At install time, package scripts, post-install hooks, and dependency loaders can run with the same permissions as the developer, CI agent, or container build step. That execution context may already include access to cloud metadata endpoints, mounted credentials, environment variables, or files generated for deployment. The package does not need exotic malware behavior. It only needs a short routine to enumerate the host for common secret locations and then make an outbound request.

Security teams should think in layers:

  • Reduce secret availability during build and install steps, especially in ephemeral runners and shared images.
  • Separate dependency resolution from privileged deployment stages so untrusted code cannot inherit production credentials.
  • Use short-lived credentials where possible, and rotate anything that may have been present in an exposed environment.
  • Monitor for unusual outbound traffic, new package behavior, and unexpected access from automation identities.
  • Validate package integrity and provenance, but do not rely on provenance alone to prevent secret theft.

This is where the identity angle becomes important. Many exposed credentials belong to service accounts, workload identities, or CI bots, which means the incident is really about non-human identity governance as much as package hygiene. The OWASP Non-Human Identity Top 10 is a strong reference point for understanding how overprivileged, long-lived, or poorly tracked machine identities amplify this risk.

Where mature teams go further, they add artifact allowlisting, hermetic builds, and dedicated secret scanners that inspect both source and runtime context. Those measures help, but they only work when the CI/CD platform is configured so that package installation happens before privileged credentials are injected. These controls tend to break down when legacy pipelines reuse the same runner across test and deploy stages because the package can inherit secrets from earlier jobs.

Common Variations and Edge Cases

Tighter package controls often increase build friction and maintenance overhead, requiring organisations to balance developer velocity against secret exposure risk.

Not every environment has the same risk profile. Public open-source projects may be more exposed to dependency confusion and typo-squatting, while enterprise pipelines may be more exposed to internal package compromise or poisoned build images. Best practice is evolving around whether install-time scripts should be disabled by default in sensitive pipelines; there is no universal standard for this yet, so the decision should be based on business criticality and the trust level of the pipeline.

There are also edge cases where secrets are not stored as obvious files or environment variables. Temporary tokens in memory, cloud instance metadata access, browser-based developer credentials, and cached federation artifacts can all be reachable from malicious package code if the runtime is too permissive. In those cases, secrets hygiene alone is not enough. Teams need identity-bound controls, runtime segmentation, and detection that can distinguish normal automation from abnormal secret retrieval. The NIST digital identity model in NIST SP 800-63 Digital Identity Guidelines is helpful when the exposed material is tied to authentication assurance, session handling, or credential lifecycle.

For organisations managing cloud workloads at scale, the practical answer is to assume that any package executing in a privileged context can be treated as a secret exfiltration opportunity unless the environment is explicitly engineered otherwise.

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 MITRE ATLAS address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-63 and NIST AI RMF set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10Malicious packages often steal machine credentials and service tokens.
NIST CSF 2.0PR.AC-1Secrets exposure is enabled by excessive access in build and runtime paths.
NIST SP 800-63AAL2Stolen credentials from packages can undermine authentication assurance and session trust.
NIST AI RMFIf AI-assisted pipelines are involved, model and tool governance affect secret leakage risk.
MITRE ATLASAML.TA0001Package abuse can resemble adversarial extraction of sensitive assets during execution.

Inventory, scope, and rotate non-human identities so package execution cannot inherit broad standing access.

NHIMG Editorial Note
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