TL;DR: Malicious npm releases tied to the Shai-Hulud campaign harvested environment secrets, GitHub PATs, npm tokens, and cloud credentials, then used a worm-like publishing loop to spread through maintainer namespaces and CI/CD pipelines, according to LEGIT Security. The incident shows that secret scanning without revocation, rebuild discipline, and package provenance controls leaves a persistent compromise path.
At a glance
What this is: This is a supply chain attack analysis of the Shai-Hulud npm worm, which combined malicious package releases with secret theft and self-propagation through maintainer namespaces.
Why it matters: It matters because CI/CD runners, developer workstations, and package trust chains can turn one compromised dependency into persistent access across identity, code, and cloud control planes.
Context
The governance gap here is not just malicious code in a package, but the assumption that package review or secret scanning alone can contain the blast radius. In practice, npm tokens, GitHub PATs, and cloud credentials can outlive the package that exposed them, especially when build systems and developer environments share trust boundaries.
For identity and access teams, this is a machine-identity and delegated-access problem as much as a software supply chain problem. The attacker used stolen credentials to move through repository, package, and cloud control planes, which means lifecycle control over secrets, tokens, and maintainer access is the real boundary under pressure.
Key questions
Q: What breaks when a malicious npm package can read developer secrets during install?
A: The main failure is that package execution inherits identity context it should never need. Once a malicious install can read environment variables, local files, and CI secrets, it can steal credentials that survive beyond the original infection. That turns a code dependency problem into an access-control incident, because the attacker gains reusable authentication material, not just a one-time foothold.
Q: Why do exposed npm tokens and GitHub PATs make supply chain incidents worse?
A: They convert a one-time package compromise into ongoing authority. With npm tokens, attackers can publish new malicious versions under a trusted namespace, and with GitHub PATs they can alter repositories, workflows, or secret stores. That is why revocation speed and credential lifecycle management matter as much as malware removal.
Q: What do security teams get wrong about secret scanning after a package compromise?
A: They often treat secret scanning as the end of the response when it is really only discovery. Finding a secret does not neutralise it, and it does not remove the access it grants. Teams also miss the need to rebuild from clean sources, which is how compromised state can be reintroduced after the package is removed.
Q: How should organisations respond when package publishing credentials are stolen?
A: Immediately revoke the stolen publishing access, review recent publishes, and rotate every adjacent credential that the compromised identity could reach. Then inspect developer endpoints for persistence, because the attacker may have left backdoors outside the package manager. Response has to cover both registry access and local workstation state.
Technical breakdown
How the post-install script turns package install into secret harvest
The malware executed after installation, which is important because post-install hooks run in the same environment that holds build-time variables, tokens, and workspace secrets. That means the package did not need interactive access to steal value. It simply inherited the privileges already present in the developer machine or CI/CD runner. In a modern pipeline, that environment often contains reusable credentials for source control, package publishing, and cloud access. The attack therefore exploited ambient trust in the install step itself, not a zero-day in npm.
Practical implication: Treat install-time execution as a sensitive control point and restrict what credentials are present when untrusted dependencies are built.
Why stolen npm tokens and GitHub PATs make the compromise self-propagating
The campaign moved beyond exfiltration by using stolen npm tokens to publish malicious updates under trusted maintainer namespaces. That turns credential theft into propagation, because the attacker no longer needs to find new victims one by one. GitHub PATs expand the same pattern into repository control, workflow tampering, and further secret collection. In identity terms, these are not just secrets, they are delegated authorities with lifecycle risk. Once exposed, they remain valid until revoked, which is why the compromise persists after the malicious package is removed.
Practical implication: Tie token exposure to immediate revocation workflows and do not rely on package removal alone to end the incident.
Why cloud credentials raise the compromise from supply chain to infrastructure abuse
Cloud service credentials in the harvested set matter because they extend the incident into runtime infrastructure. With valid AWS, GCP, or Azure credentials, an attacker can read data, alter resources, deploy further payloads, or create persistence outside the package ecosystem. That is the weak link in secret governance: organisations often separate software supply chain controls from cloud access controls even though the same exposed secret can bridge both. The practical result is a longer-lived foothold and a much wider response scope than dependency replacement alone suggests.
Practical implication: Map exposed secrets to their downstream entitlements so cloud containment and source control containment happen together.
Threat narrative
Attacker objective: The attacker aimed to turn one compromised package installation into durable access across package publishing, code repositories, and cloud environments.
- Entry occurred when malicious npm packages were published with post-install scripts that ran inside developer and CI/CD environments.
- Credential harvest followed as the malware collected environment secrets, GitHub PATs, npm tokens, and cloud credentials from those environments.
- Escalation happened when stolen npm tokens were used to publish additional malicious package versions under maintainer namespaces, creating worm-like spread.
- Impact was persistent compromise across source code, package publishing, and cloud infrastructure, even after the malicious packages were removed.
Breaches seen in the wild
- tj-actions/changed-files compromise 2025: A stolen bot token let attackers poison tj-actions/changed-files so pipelines printed their CI/CD secrets to public logs (CVE-2025-30066).
- Shai-Hulud npm worm first wave 2025: The first Shai-Hulud wave used stolen npm tokens to trojanise 500+ packages, starting with tinycolor, and leaked developer and CI secrets on GitHub.
Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.
NHI Mgmt Group analysis
Secret governance fails when credentials outlive the package that exposed them. The attack shows that scanning for secrets is only one control layer, because exposed npm tokens, GitHub PATs, and cloud keys remain valid until someone revokes them. In practice, the failure mode is persistent authority, not just secret discovery. That makes lifecycle control the decisive issue for both NHI governance and software supply chain risk.
Worm-like package propagation is a governance problem, not only a malware problem. Once a maintainer token can publish new malicious releases, the attacker has turned delegated package authority into an internal distribution channel. That is a direct example of how machine identities and service credentials can become propagation assets when ownership, rotation, and offboarding are weak. Practitioners should read this as a control boundary failure across registry, repository, and build systems.
Shai-Hulud is a named concept for credential-led supply chain persistence. The important pattern is not simply package compromise, but the combination of secret theft, namespace reuse, and continued publishing rights after initial infection. This is the kind of failure that conventional dependency hygiene misses because it treats packages as artifacts rather than as access-bearing control points. The practitioner conclusion is to govern package credentials like privileged identities.
CI/CD runners are high-value secret containers and should be treated that way. The article’s emphasis on runners, environment variables, and build-time access shows why pipeline trust is now an identity issue as much as a software issue. When the build environment can read secrets and publish artefacts, it sits inside the attack path. That requires tighter lifecycle control, not just better scanning.
Recovery has to include provenance, not just revocation. If affected projects are rebuilt from the same compromised state or from artefacts that were signed, cached, or produced after exposure, the organisation can reintroduce the compromise. Provenance checks and clean rebuild discipline are therefore part of the governance response, especially where package publishing and cloud access intersect.
From our research library:
- 59% of compromised machines in a major 2025 supply chain attack were CI/CD runners rather than personal workstations, according to the State of Secrets Sprawl 2026.
- 92% of organisations expose NHIs to third parties, raising concerns about supply chain security, according to the Ultimate Guide to NHIs.
- Read next: Guide to the Secret Sprawl Challenge
What this signals
Namespace trust has become a propagation problem. Once an attacker can use stolen package credentials to publish under a maintainer namespace, the registry itself becomes part of the attack path. That shifts the practitioner focus from single-package screening to publishing authority, secret lifetime, and repo-to-registry trust boundaries.
CI/CD secret exposure is now a supply chain control issue, not a narrow pipeline hygiene issue. If runner environments can read high-value tokens, a malicious install can pivot from dependency compromise into repository and cloud persistence in one execution path. Teams should prepare for that boundary to be tested repeatedly, especially where build systems hold broad credentials.
For practitioners
- Revoke exposed maintainer and cloud tokens immediately Treat GitHub PATs, npm tokens, and cloud keys from affected environments as compromised until proven otherwise, and revoke them through the same incident workflow that handles code access.
- Rebuild affected projects from clean sources Remove or roll back the malicious package versions, then rebuild from a trusted source or artifact repository rather than from any workspace that may have executed the post-install script.
- Inspect CI/CD runners for secret exposure Review runner inventories, environment variables, and job logs for secrets that were present during the attack window, because build infrastructure may have been the actual credential source.
- Search for malicious repository artefacts Check for the Shai-Hulud repository and inspect its history and contents to understand what secrets may have been exfiltrated and whether any follow-on workflow files were created.
- Tighten package publishing permissions Reduce who can publish under maintainer namespaces and separate package publication credentials from everyday development access so stolen tokens cannot easily become a propagation path.
Key takeaways
- The attack shows that secret governance fails when credentials remain valid after a malicious package is removed.
- The practical blast radius spans source control, package publishing, and cloud access because the stolen secrets bridged all three.
- Rebuild discipline, token revocation, and publishing-credential containment are the controls that change the outcome.
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 ATT&CK address the attack and risk surface, while CIS Controls v8, NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | The article centres on exposed secrets from npm, GitHub, and cloud environments. |
| NHI-03 — Vulnerable Third-Party NHI | The malicious package acted as a third-party identity path into maintainer namespaces. | |
| NHI-07 — Long-Lived Secrets | Stolen tokens remained useful until revocation, extending the compromise beyond package removal. | |
| Recommendation — Hunt for exposed NHI secrets in build logs, repositories, and runners, then revoke them immediately. Assess third-party package credentials as external identity trust and constrain their publication rights. Shorten credential lifetimes and enforce rapid revocation for any secret used in build or publish workflows. | ||
| MITRE ATT&CK | TA0006;TA0008 — Credential Access; Lateral Movement | The campaign harvested credentials and used them to move across repositories and package namespaces. |
| TA0010 — Exfiltration | The malware’s post-install behaviour explicitly exfiltrated harvested secrets to attacker infrastructure. | |
| Recommendation — Map token theft and namespace spread to TA0006 and TA0008 in detection and response playbooks. Correlate install-time network activity and outbound secret exfiltration with TA0010 detections. | ||
| CIS Controls v8 | CIS-5 — Account Management | Maintainer and runner credentials require lifecycle governance and prompt removal after exposure. |
| Recommendation — Apply account lifecycle controls to publishing identities and revoke unused access paths quickly. | ||
| NIST CSF 2.0 | PR.AA-05 — Access Permissions, Entitlements and Authorizations | The article shows how overbroad entitlements in runners and tokens widened the blast radius. |
| Recommendation — Review entitlements for runners and maintainer accounts so only the minimum publication scope remains. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Token rotation and revocation are central to limiting the persistence of exposed credentials. |
| Recommendation — Enforce authenticator rotation and revocation procedures for npm, GitHub, and cloud credentials. | ||
Key terms
- Secrets Governance: Secrets governance is the discipline of controlling where credentials are stored, who can use them, how long they remain valid, and how they are removed. It links discovery, rotation, offboarding, and auditability so that a secret does not outlive the legitimate need for access.
- CI/CD runner: A CI/CD runner is the execution environment that performs build, test, or deployment jobs. It often has access to source code, tokens, and cloud credentials, which makes it a high-value identity surface when workflows are compromised.
- Package Namespace: A package namespace is the structured naming path used to identify and organize software components. In ecosystems such as Java, namespace conventions help users infer publisher identity and library lineage, which is why attacker-controlled lookalikes can be effective when they mimic established naming patterns too closely.
- Postinstall Script: A package lifecycle hook that runs automatically after installation. It is useful for legitimate setup tasks, but it also creates an execution path that can be abused to run malicious code as soon as a dependency is installed.
Deepen your knowledge
NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, secrets management, and machine identity security. It helps practitioners connect identity lifecycle control to the build and release systems that now carry real operational risk.
Published by the NHIMG editorial team on August 19, 2026.
Updated on October 12, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org