Hiking-Logbook

Security Audit Report: NPM Supply Chain Attack (@ctrl/tinycolor)

Summary

This report documents the recent npm supply-chain trojanization campaign that included malicious updates to @ctrl/tinycolor and dozens of other packages. The compromised releases installed a postinstall script that executed a bundled bundle.js which scanned hosts for secrets (TruffleHog), attempted to validate and use found tokens, created GitHub Actions workflows, and exfiltrated findings to a hard-coded webhook. The campaign also contained logic to repack and republish trojanized downstream packages when publishing credentials were accessible.


Key incident facts


1. What Caused the Supply Chain Attack? (Point of Failure)

Primary point of failure

How it occurred (brief chain)

  1. A package version containing a postinstall hook that runs bundle.js was published.
  2. When installed, the postinstall script executed and ran a controller (bundle.js) that downloaded/ran TruffleHog to hunt for credentials and tokens.
  3. If secrets (e.g., NPM_TOKEN, GITHUB_TOKEN, cloud keys) were present and valid, the script validated them (for example, via https://registry.npmjs.org/-/whoami) and used them to interact with registries and APIs.
  4. The controller could repackage packages, inject malicious bundle.js and postinstall into other packages, and publish those if publishing credentials were available — thus propagating the trojanization.
  5. It also planted GitHub Actions workflows in repositories to persist exfiltration from CI environments.

Contributing operational failures


2. List of Compromised Packages and Their Versions

(As reported in the incident — this list may have expanded during the active campaign.)

IOC: bundle.js SHA-256 46faab8ab153fae6e80e7cca38eab363075bb524edd79e42269217a083628f09 and exfil endpoint hxxps://webhook[.]site/bb8ca5f6-4175-45d2-b042-fc9ebb8170b7.


3. Report of Our Packages (Frontend & Backend) — Compromise Check

Note: The checks below should be run in your environment. This report states recommended checks and the automated tooling previously provided.

Automated checks you should run now

Recommended immediate posture


4. Report of Our Packages’ Packages (Sub-dependencies)

What to check

Suggested commands

# list where package is pulled from
npm ls @ctrl/tinycolor || true
# search lockfile for exact matches
grep -n "@ctrl/tinycolor@" package-lock.json || true

Recommended outcome interpretation


5. Measures to Avoid Being Infected by Upstream Packages (Protecting Against Supply Chain Attacks)

Immediate actions

Policy & operational controls

Technology & detection


6. Measures to Avoid Your Product Being Infected (Protecting Your Own Project)

Developer & CI hygiene

Runtime & pipeline detection

Recovery steps


7. Automated Tools & Suggested Scripts


8. Conclusion

This incident demonstrates how install-time scripts combined with available credentials can enable rapid, automated trojanization of packages and persistence in repositories via CI workflows. The prioritized defenses are: remove credentials from risky hosts, pin and vet dependencies, block or audit install-time scripts for sensitive builds, and add layered detection (secret scanning, publish monitoring, SBOM verification). Run the provided automated checks now and attach the outputs to your sprint submission.