npm math packages hide matrix-triggered backdoor
SafeDep analyzed a software supply chain attack in npm package mathmain and related clones that mimic the mathjs library. The package conceals an encrypted backdoor that remains dormant until solving a specific 3x3 Pascal matrix, then leverages Slack, Telegram, and Base Sepolia smart contracts for remote command execution.
Tying payload decryption directly to runtime mathematical inputs marks a chilling evolution in supply chain tradecraft, rendering conventional static analysis and automated sandboxes virtually powerless.
- –Mathematical logic bombs: Deriving the decryption key from runtime matrix decomposition means security tools cannot decrypt or analyze the payload without capturing the attacker's specific trigger equation.
- –Publishing pipeline discrepancies: The malicious loader was introduced exclusively inside the published npm tarballs while the public GitHub repositories were kept clean, exploiting trust gaps between source code and build artifacts.
- –Hybrid C2 architecture: Decrypted stages blend enterprise messaging APIs (Slack and Telegram) with Web3 smart contracts on the Base Sepolia testnet to coordinate shell execution without relying on easily blockable traditional C2 domains.
- –Registry telemetry distortion: The implicated packages logged millions of downloads despite having zero public dependents and minimal CDN traffic, underscoring systemic issues in detecting automated or artificial download inflation.
DISCOVERED
1h ago
2026-09-21
PUBLISHED
3h ago
2026-09-21
RELEVANCE
AUTHOR
abhisek