← Terug naar blog

Containment analysis, and mitigation of the “Shai Hulud” supply chain malware campaign

AI Security

1. Summary

This advisory constitutes a analysis of the “Shai Hulud” malware campaign, a sophisticated, self-replicating supply chain attack targeting the JavaScript/TypeScript (NPM) ecosystem. This threat poses a critical and active risk to the Dutch public sector’s Continuous Integration/Continuous Deployment (CI/CD) pipelines, particularly within the context of the Judiciary (Rechtspraak), given the extensive reliance on open-source dependencies for digital service delivery and the modernization of judicial applications.

The attack has evolved through two distinct phases: an initial wave in September 2025 targeting widely used libraries such as @ctrl/tinycolor and ngx-bootstrap, and a more aggressive “Second Coming” (v2) observed in late November 2025. This second variant leverages the Bun runtime for evasion, operates during the preinstall phase to maximize infection rates, and includes destructive “wiper” capabilities designed to destroy victim data upon detection or containment attempts. The malware operates as a worm, utilizing stolen NPM publisher tokens to automatically infect downstream dependencies, creating an exponential blast radius that threatens the integrity of the national software supply chain.

Key Findings & Strategic Risks:

Immediate Recommendations (BLUF):

2. Technical Anatomy of the Attack

The “Shai Hulud” campaign represents a paradigm shift in NPM supply chain attacks, moving from simple credential theft (like the event-stream incident) to automated, worm-like propagation with destructive failsafes. The analysis below dissects the kill chain of the v2 variant (“The Second Coming”), which poses the highest current threat to the Judiciary’s infrastructure.

2.1. Infection Vector: The “Preinstall” Shift

Unlike the v1 variant which relied on postinstall scripts, the v2 variant executes during the preinstall lifecycle phase. This is a critical tactical evolution. The preinstall script runs immediately when npm install is executed, often before vulnerability scanners or Software Composition Analysis (SCA) tools have completed their assessment of the dependency tree. This ensures the malware runs even if the installation ultimately fails or is cancelled by the user.1

The infection begins with a compromised dependency (e.g., a trojanized version of @asyncapi/specs, @ctrl/tinycolor, or posthog-node) containing a modified package.json:

JSON

“scripts”: {  “preinstall”: “node setup_bun.js”}This triggers the execution of the dropper script, setup_bun.js, which initiates the malware’s bootstrap process. The choice of preinstall is deliberate; it catches developers and CI systems off-guard, executing code the moment they attempt to consume the package.

2.2. The Dropper: setup_bun.js and Bun Runtime Evasion

The attackers have chosen to utilize the Bun runtime environment rather than standard Node.js for the execution of the main payload. This serves as a potent evasion technique. Many Endpoint Detection and Response (EDR) and container security tools are tuned to monitor node, npm, or python processes for suspicious child processes or network connections. However, bun is a newer, faster runtime that may not be on the radar of legacy security monitoring rules, or may be whitelisted as a developer tool.11

Mechanism of setup_bun.js:

2.3. The Core Payload: bun_environment.js

The bun_environment.js file is a large (~10MB), heavily obfuscated JavaScript file containing the malware’s primary logic. It functions as a modular attack framework with distinct capabilities for reconnaissance, harvesting, exfiltration, and destruction. The size and obfuscation are designed to hinder static analysis and reverse engineering.13

2.3.1. Credential Harvesting & “TruffleHog” Abuse

The malware creates a directory structure (often hidden, such as .truffler-cache) and downloads a standalone binary of TruffleHog, a legitimate open-source security tool used for finding secrets. By weaponizing a legitimate security tool, the attackers ensure high-fidelity secret detection while potentially blending in with legitimate DevSecOps activities—a “Living off the Land” (LotL) tactic.5

Targeted Credentials:

2.3.2. Worm Propagation Mechanism

This is the defining characteristic of “Shai Hulud.” The malware checks for a valid NPM publishing token in the victim’s .npmrc file or environment variables. If a write-access token is found:

This automated self-replication allows the malware to move laterally from a single compromised developer workstation to potentially hundreds of trusted libraries within minutes. In the initial waves, this mechanism was responsible for infecting over 500 packages.5

2.3.3. Persistence via GitHub Actions

To maintain access even if the infected package is removed from the registry or the developer cleans their machine, the malware establishes persistence within the victim’s GitHub repositories:

2.4. Destructive Capability: The “Dead Man’s Switch”

Perhaps the most critical finding for incident responders is the malware’s destructive fallback mechanism. Code analysis reveals a conditional logic block that functions as a wiper. This capability transforms the threat from purely espionage to potential sabotage.

Trigger Conditions:

The wiper is triggered if the malware cannot authenticate to GitHub (preventing data exfiltration) AND cannot find a valid NPM token (preventing propagation).4 This behavior suggests a “scorched earth” policy: if the malware determines it has been cornered, analyzed in a sandbox without internet access, or if the victim has revoked credentials but not removed the active malware process, it destroys evidence and inflicts damage.

Destructive Logic:

Operational Implication: This creates a significant risk during containment. Simply severing the network connection of an active infection before suspending the process could trigger this wiper logic, as the malware will interpret the loss of connectivity to GitHub/NPM as a trigger condition.

3. Impact Assessment (Dutch Public Sector Context)

The threat profile for the Dutch Judiciary (Rechtspraak) and the broader public sector is categorized as CRITICAL. The heavy reliance on modern JavaScript frameworks (Angular, React, Vue) and the NPM ecosystem for digital services (e.g., Mijn Rechtspraak, digital filing systems, case management interfaces) creates a broad and fertile attack surface for this campaign.

3.1. Likelihood of Exposure

The likelihood of exposure is High.

3.2. Data Exfiltration Risks

The specific risk to the Judiciary involves the exfiltration of high-sensitivity technical secrets, which can lead to secondary compromises and lateral movement:

3.3. “Wormable” Propagation within Internal Registries

A unique and dangerous vector is the potential for the worm to infect private/internal packages. If a developer with write access to the organization’s private NPM registry (e.g., an internal Artifactory instance hosted within the Rechtspraak network) is infected, the malware will attempt to publish infected versions of internal packages.15

This would effectively poison the internal supply chain. The malware would then spread to every other internal project that consumes these private libraries, bypassing perimeter defenses and moving laterally across development teams. This “insider threat” mechanic turns trusted developers into unwitting vectors of infection.

4. NIS2 Compliance & Regulatory Impact

Under the NIS2 Directive (EU 2022/2555), transposed into Dutch law via the Cyberbeveiligingswet, the Judiciary and associated digital service providers are classified as essential or important entities. This classification imposes strict legal obligations regarding supply chain security and incident reporting.

4.1. “Significant Incident” Determination

A successful infection by Shai Hulud constitutes a “significant incident” under NIS2 and the Wbni (Wet beveiliging netwerk- en informatiesystemen) based on the following criteria:

4.2. Reporting Obligations (NCSC-NL & CSIRT-DSP)

Upon detection of a Shai Hulud infection, the organization is legally obligated to adhere to the strict reporting timelines mandated by NIS2 8:

4.3. BIO v1.2 Alignment (Baseline Informatiebeveiliging Overheid)

The incident highlights critical gaps in compliance with BIO v1.2 controls regarding software development and supply chain security.25 The BIO is the mandatory baseline for Dutch government information security.

5. Detection & Threat Hunting Strategy

To detect active or past infections, the SOC must execute a coordinated threat hunting campaign across endpoints (developer workstations) and CI/CD infrastructure. The following strategies leverage the indicators identified in the technical analysis.

5.1. Log & Network Analysis Queries

Query 1: Outbound Traffic to Exfiltration Domains

The malware exfiltrates data to specific endpoints. Block and alert on traffic to the following domains. Note that webhook.site is a legitimate service often used for testing, but its presence in CI logs is highly suspicious.

Query 2: Suspicious Process Execution (EDR/Sigma)

Look for the execution of the installation script, the dynamic installation of Bun, or the hidden TruffleHog binary.

YAML

Sigma Logic for Detection (Conceptual)detection:  selection_dropper:    CommandLine|contains:      – ‘node setup_bun.js’      – ‘curl -fsSL https://bun.sh/install’      – ‘irm bun.sh/install.ps1’  selection_trufflehog:    CommandLine|contains:      – ’trufflehog filesystem’      – ’trufflehog –json’      – ’trufflehog filesystem /’  selection_wiper:    CommandLine|contains:      – ‘shred -uvz’      – ‘cipher /W:%USERPROFILE%’  condition: selection_dropper or selection_trufflehog or selection_wiper3

Query 3: GitHub Actions Anomaly Detection

Scan GitHub audit logs for specific anomalies related to the persistence mechanism:

5.2. File System Indicators (IoCs)

Presence of any of the following files on a developer machine or build agent indicates a compromise:

5.3. Identifying “Trojanized” Internal Packages

To determine if internal packages (@rechtspraak/*) have been compromised and republished to the internal registry:

6. Mitigation & Hardening Roadmap

This section outlines the immediate steps to sanitize the environment and the strategic measures to harden the supply chain against future wormable attacks.

6.1. Immediate Containment (The “Anti-Wiper” Protocol)

CRITICAL WARNING: Due to the “dead man’s switch” (wiper), simply disconnecting a machine from the internet may trigger the destructive payload if the malware is active and detects the loss of connectivity to GitHub/NPM.

6.2. Short-Term Remediation (24-48 Hours)

6.3. Strategic Hardening (Sovereign & Resilient Architecture)

To align with the “Data Platform as Product” and “Sovereign Cloud” goals found in the workspace research, the following architectural changes are recommended to prevent future recurrence.

6.3.1. Isolate Build Environments & Private Registries

6.3.2. Implement OIDC for Publishing

Eliminate long-lived NPM tokens entirely. Adopt OpenID Connect (OIDC) for trusted publishing.

6.3.3. Harden CI/CD Runners

6.3.4. Software Bill of Materials (SBOM) Enforcement

Implement automated SBOM generation (using tools like Syft or CycloneDX) for every build. Ingest these SBOMs into a dependency track system (e.g., OWASP Dependency-Track) to continuously monitor for the introduction of malicious packages like @ctrl/tinycolor across the entire application portfolio. This provides visibility into “phantom dependencies” that may not appear in the root package.json.36

7. Conclusion

The Shai Hulud campaign demonstrates that the NPM ecosystem is being weaponized with increasing sophistication, moving from simple theft to automated destruction. For the Dutch Judiciary, the combination of data exfiltration and destructive capabilities necessitates a shift from reactive patching to proactive supply chain defense. By implementing strict egress controls, adopting OIDC for identity-based access, and adhering to the NIS2 reporting framework, the organization can contain this threat and build resilience against the next generation of supply chain worms. The immediate priority is the safe containment of any infected nodes to prevent data destruction, followed by a rigorous audit of credentials and dependencies.

Appendix A: IoC Database

The following indicators of compromise are associated with the Shai Hulud v2 campaign.

Indicator TypeValue / PatternDescription****File Hash (SHA256)a3894003ad1d293ba96d77881ccd2071446dc3f65f434669b49b3da92421901asetup_bun.js (Dropper)File Hash (SHA1)d60ec97eea19fffb4809bc35b91033b52490ca11bun_environment.js (Payload)File Namesetup_bun.js, bun_environment.jsMalicious scripts found in package rootFile NametruffleSecrets.json, cloud.json, environment.json, contents.jsonStaging files for exfiltrated dataNetwork Domainwebhook.siteC2 / Exfiltration EndpointNetwork Domainbun.shUnauthorized download of Bun runtimeGitHub RepoDescription: “Sha1-Hulud: The Second Coming”Repositories created by malwareGitHub RunnerName: SHA1HULUDMalicious self-hosted runnerPackage Name@ctrl/tinycolorVersions 4.1.1, 4.1.2 (Compromised)Package Namengx-bootstrapCompromised versions (check specific advisories)Package Name@asyncapi/specsCompromised versions (check specific advisories)

2

Geciteerd werk

DjimIT Nieuwsbrief

AI updates, praktijkcases en tool reviews — tweewekelijks, direct in uw inbox.

Gerelateerde artikelen