Malicious npm Packages Hide Payloads in Runtime Behavior to Evade Install Protections

· Original article ↗

Summary

Checkmarx found indexed-btree and nine related npm packages impersonating legitimate libraries. The malware triggers at runtime, collects system details and uses an Ethereum smart contract for C2; developers are advised to rotate secrets and restore affected systems.

Key points

  • indexed-btree impersonates the legitimate sorted-btree library and reportedly reached 2 million weekly downloads.
  • The malware avoids install scripts and hides its loader in BTree.prototype.set(), triggering when the application calls the method with a specific key.
  • The payload can collect system details, including hostname, architecture, CPU, memory and uptime, and exfiltrate them through Slack and Telegram.
  • It polls an Ethereum smart contract on the Sepolia test network for C2 information and decrypts a second-stage payload using an AES key derived through X25519 key exchange.
  • The malware can delete its files and remove its trigger from package code when operators end the attack, according to the report.
  • Checkmarx identified nine related npm packages, which it says have been removed from npm.
  • Developers who installed the packages are advised to rotate secrets and restore their development environments from a safe backup; runtime behavioral analysis is recommended.

Article Details

Attack Vectors
  • Malicious npm packages impersonated the legitimate sorted-btree library and concealed a loader in BTree.prototype.set(), triggering when called with a specific key at runtime rather than through an installation script.
  • The loader triggered an obfuscated first-stage payload in sharedLoad.min.js. The malware collected system details and exfiltrated them through Slack and Telegram channels.
  • The malware polled an Ethereum smart contract on the Sepolia test network for command-and-control information and decrypted a second-stage payload stored in the contract using a key derived through X25519 key exchange.
  • The operators could delete files and remove the malicious trigger from package code to erase traces.
Defensive Notes
  • Do not rely on install-time scanning alone; use runtime behavioral analysis.
  • Developers who installed indexed-btree or any of the nine related packages should rotate all secrets and restore their development environment from a safe backup.

MITRE ATT&CK

Products

Related Articles