When NPM Goes Rogue: The @ctrl/tinycolor Supply-Chain Attack

September 15, 2025

On September 15, 2025, researchers at StepSecurity and Socket disclosed a large, sophisticated supply-chain compromise in the NPM ecosystem. The incident centers around the popular package @ctrl/tinycolor (with over two million weekly downloads), but it extends far beyond: 40+ other packages across multiple maintainers were also compromised. 

What makes this attack especially dangerous is its breadth (many packages), its depth (credential harvesting, cloud secrets access), and its persistence mechanisms (GitHub Actions backdoors, forced package propagations). This post breaks down how the attack works, which packages are affected, and how organisations (and individual devs) can detect and mitigate the damage.

Credit for the original discovery goes to researchers from Socket.dev and StepSecurity. 

written by
Kodem Security Research Team
published on
September 16, 2025
topic
Vulnerabilities

Technical Analysis

Here is how the attack is structured, in stages:

  1. Initial Compromise & Post-Install Payload
    A malicious bundle (≈ 3.6 MB, minified, “bundle.js”) is injected into compromised package versions. The actor uses postinstall hooks (in package.json) to ensure that code runs during npm install.
  2. Self-Propagation Across Maintained Packages
    Once the malware has control (via a user’s NPM credentials/NPM_TOKEN), it queries the NPM registry to find all packages maintained by that user (up to 20), and force-publishes patched versions including the malicious bundle. This allows cascading compromise across the owner’s entire package portfolio.
  3. Credential & Secret Harvesting
    • Dumps environment variables (process.env) to look for tokens like AWS_ACCESS_KEY_ID, GITHUB_TOKEN, etc.
    • Uses tools like TruffleHog to scan the filesystem for high-entropy secrets.
    • Accesses cloud secret stores: AWS Secrets Manager, Google Cloud Secret Manager, Azure credentials, metadata endpoints where possible.
  4. Persistence via GitHub Backdoor
    A malicious GitHub Actions workflow file, named something like .github/workflows/shai-hulud-workflow.yml, is injected. It triggers on push events, uses a base64-encoded script to exfiltrate secrets via $ {{ toJSON(secrets) }} to a remote endpoint. As part of this, the attacker may create a branch shai-hulud or force patches into existing repos.

Evasion & Silent Failures
The malware hides its activity: error handling swallows failures, no conspicuous logs, various modules are modularized so only needed code is loaded. It also deliberately excludes Windows hosts (activates only on Linux or macOS).

Impacted Packages

Here is the confirmed list of compromised packages and their versions. If your projects depend on any of them (directly or transitively), treat them as suspect.

Detection & Mitigation

Here are actionable steps for detection and mitigation (both immediate and longer-term) from Kodem’s Security Research Team:

Immediate Steps

  • Audit your dependency tree. Use npm ls <package> (or equivalent in Yarn/pnpm) to check if you depend (directly or indirectly) on any of the above compromised packages. Remove or pin to safe versions (if available).
  • Search for the known malicious bundle. The SHA-256 hash of the compromised bundle.js is:
    46faab8ab153fae6e80e7cca38eab363075bb524edd79e42269217a083628f09
  • Inspect GitHub repositories in your organisation for the malicious workflow file .github/workflows/shai-hulud-workflow.yml, and branches named shai-hulud. Remove them.
  • Rotate credentials: any NPM tokens, GitHub PATs, cloud credentials (AWS, GCP, Azure), SSH keys, CI/CD secrets, etc. Assume they may have been exposed.

Medium & Long-Term Defenses

  • Least privilege for automation tokens. Ensure that tokens used for publishing or CI only have exactly the permissions needed. Separate credentials used for publishing from those with broad access.
  • Use code review / dependency gating. Implement policies (e.g. via CI) that require review when adding or upgrading dependencies; particularly new versions of packages with large download counts.
  • Monitor publishing activity. Tools that detect anomalous publishes (e.g. new versions in quick succession, forced patches) are valuable.
  • Audit cloud secret access logs regularly. For AWS, GCP, Azure: audit access to Secrets Manager, look for unusual or suspicious secret reads, cross-region access, unexpected service account key creation.
  • Enable branch protections, secret scanning, workflow approvals in GitHub (or equivalent) to reduce risk from malicious workflows.
  • Supply chain risk awareness. For organisations, maintain an inventory of dependencies; understand which maintainers are shared; understand transitive dependency risks.

Why This Matters & Lessons Learned

  • Supply chain attacks are evolving. This one is not just about inserting malicious code into one package; it self-propagates via maintainer accounts, cloud creds, GitHub workflows.
  • Wider blast radius. With over 40 packages affected, and many downstream consumers, the risk of exposure is very large, across many projects and organisations.
  • Detection is hard when evasion is baked in. Silent failures, modular payloads, skipping Windows hosts, using base64 and obfuscation, all make this harder to detect until damage is done.
  • Importance of proactive measures. Having detection tools in place before compromise (like monitoring publish events, gating dependency upgrades, reviewing workflows) can mitigate damage.

Conclusion

The @ctrl/tinycolor compromise is a stark reminder that even trusted, popular packages in NPM can become attack vectors. The layers of malicious behavior here (credential harvesting, propagation, GitHub backdoors) make this especially dangerous. Developers, maintainers, and security engineers need to assume breach: inspect dependencies, log and audit cloud credentials, enforce least privilege, and incorporate supply chain risk checks into CI/CD.

If you believe you or your organisation may have been affected, act immediately: remove compromised dependencies, rotate credentials, search for backdoor workflows, audit systems. Then, review and strengthen your processes to reduce risk in the future.

References

Here are sources and additional reading:

Blog written by

Kodem Security Research Team

More blogs

View all

Malicious Packages Alert: The Qix npm Supply-Chain Attack: Lessons for the Ecosystem

The npm ecosystem is in the middle of a major supply-chain compromise. The maintainer known as Qix is currently targeted in a phishing campaign that allows attackers to bypass two-factor authentication and take over their npm account. This is happening right now, and malicious versions of widely used libraries are being published and distributed.

September 8, 2025

Security Issues in popular AI Runtimes - Node.js, Deno, and Bun

Node.js, Deno, and Bun are the primary runtimes for executing JavaScript and TypeScript in modern applications. They form the backbone of AI backends, serverless deployments, and orchestration layers. Each runtime introduces distinct application security issues. For product security teams, understanding these runtime weaknesses is essential because attacks often bypass framework-level defenses and exploit the runtime directly.

September 8, 2025

Application Security Issues in AI Edge and Serverless Runtimes: AWS Lambda, Vercel Edge Functions, and Cloudflare Workers

AI workloads are increasingly deployed on serverless runtimes like AWS Lambda, Vercel Edge Functions, and Cloudflare Workers. These platforms reduce operational overhead but introduce new application-layer risks. Product security teams must recognize that serverless runtimes are not inherently safer—they simply shift the attack surface.

September 8, 2025

A Primer on Runtime Intelligence

See how Kodem's cutting-edge sensor technology revolutionizes application monitoring at the kernel level.

5.1k
Applications covered
1.1m
False positives eliminated
4.8k
Triage hours reduced

Platform Overview Video

Watch our short platform overview video to see how Kodem discovers real security risks in your code at runtime.

5.1k
Applications covered
1.1m
False positives eliminated
4.8k
Triage hours reduced

The State of the Application Security Workflow

This report aims to equip readers with actionable insights that can help future-proof their security programs. Kodem, the publisher of this report, purpose built a platform that bridges these gaps by unifying shift-left strategies with runtime monitoring and protection.

Get real-time insights across the full stack…code, containers, OS, and memory

Watch how Kodem’s runtime security platform detects and blocks attacks before they cause damage. No guesswork. Just precise, automated protection.

Stay up-to-date on Audit Nexus

A curated resource for the many updates to cybersecurity and AI risk regulations, frameworks, and standards.