On September 8, 2025, a poisoned build of ansi-styles -- a tiny, ubiquitous npm utility with more than 74 billion lifetime downloads -- was published to the registry as version 6.2.2. The release looks almost identical to its predecessor, but a single file, the package's entry point index.js, was rewritten to carry a heavily obfuscated browser-side crypto wallet drainer. Armando's analysis traces this release to the broader "chalk/debug" supply-chain incident, in which the npm accounts behind several core utility packages were compromised through a phishing attack and used to ship the same drainer payload.
Key Findings
- Malicious version: v6.2.2, published 2025-09-08; v6.2.1 is clean
- Entry point: the package's main module
index.js -- the payload runs when the module is loaded in a browser context, with no install hook required
- Targets: browser-based cryptocurrency users -- the payload hooks wallet APIs to silently redirect transactions and token approvals to attacker-controlled addresses
- Evasion: the entire payload is wrapped in a
_0x180f string-array decoder with arithmetic index obfuscation, and is appended after the genuine ansi-styles code so the module still behaves normally
- Detection: Script-JS.Trojan.SupplyChain, Text.Trojan.SupplyChain, Archive-GZIP.Trojan.SupplyChain, Archive-TAR.Trojan.SupplyChain
Package Background
ansi-styles provides ANSI escape codes for styling strings in the terminal. It has been published since July 2013, has accumulated over 74 billion downloads, and is directly imported by more than 6,200 packages. It sits deep in the dependency graph of the JavaScript ecosystem -- pulled in transitively by the chalk family and countless build tools -- which is exactly what made it such an effective supply-chain target. A package this small and this trusted is rarely re-inspected; almost no one reads the source of ansi-styles before every build.
The package's npm publisher footprint resolves to a long-standing maintainer account (jbnicolai) tied to the chalk/ansi organization, with a history reaching back to 2011 and a portfolio of legacy utilities. That established trust, not a throwaway account, is the point: this was an account takeover of a legitimate maintainer, consistent with the phishing campaign that drove the September 2025 chalk/debug compromise -- not a disposable attacker persona.