Malicious code in hd-key-generator (npm)
hd-key-generator is a typosquat package on npm that executes malicious code on require(), exfiltrating environment variables (including secrets like AWS_*, GITHUB_TOKEN, NPM_TOKEN), system information, and package metadata to a hardcoded Telegram Bot API endpoint.
- Disclosed
- Last updated
- Blast radius
- Any developer or CI/CD system that installed hd-key-generator expecting the legitimate hdkey package
- Ecosystems
- Attack vectors
- Affected entities
- hd-key-generatorTyposquat of hdkey package; exfiltrates environment variables and system information to Telegram Bot API
hd-key-generator is a malicious npm package that impersonates the legitimate hdkey library through typosquatting. Upon being required, the package's index.js reads sensitive data including process.env, os.hostname(), os.userInfo().username, the user's home directory, platform, current working directory, and package metadata.\n\nThe collected data is JSON-serialized, base64-encoded, and exfiltrated via HTTPS GET request to a hardcoded Telegram Bot API endpoint (api.telegram.org/bot/sendMessage) with chat_id=8969499041. A temporary marker file is used to prevent repeated transmissions of the same data.\n\nThe package attempts to preserve functionality by re-exporting the legitimate hdkey package if present on the system, or returning stub functions otherwise. This deceptive behavior increases the likelihood of the malicious code going undetected.\n\nThe full process.env dump is particularly dangerous as it captures any secrets exported by the installer's shell or CI environment, including AWS credentials, GitHub tokens, NPM tokens, and database credentials.
Indicators of compromise
- Packages
- hd-key-generator
Remediation
- Immediately uninstall hd-key-generator from all systems and CI/CD pipelines
- Audit npm package.json files and lock files for any references to hd-key-generator
- Rotate all secrets and credentials that may have been exposed (AWS keys, GitHub tokens, NPM tokens, database passwords, etc.)
- Review Telegram Bot API logs if accessible to determine what data was exfiltrated
- Install the legitimate hdkey package if the functionality is required
- Implement package name verification and allowlisting in dependency management to prevent typosquat attacks
- Enable npm audit and supply chain security scanning tools to detect malicious packages
Sources
- GitHub Advisory GHSA-pgv7-rwgc-x373 · GitHub Advisory Database
Cite this entry
"Malicious code in hd-key-generator (npm)." supplychainattack.org, Supply Chain Attack Incident Catalog. Disclosed August 5, 2026; last updated August 5, 2026. https://supplychainattack.org/incident/malicious-code-in-hd-key-generator-npm-aeibxx
Suggest a correction
Found an error or have a newer source? Corrections to factual errors take priority over new entries.
Related incidents
- resolvedcritical
Malicious code in akamai-sensor (npm)
A malicious npm package named akamai-sensor impersonated Akamai's legitimate sensor_data anti-bot SDK. The package contained hidden JavaScript code concealed using invisible Unicode characters and implemented a dynamic command-and-control channel via a Google Calendar dead-drop, enabling arbitrary code execution on installation.
npmCompromised packageTyposquatting - resolvedcritical
Malicious code in @finaxis/common-js (npm)
The npm package @finaxis/common-js was published with a README and keywords copied from lodash v4.18.1, but contained a heavily obfuscated Xelis (XEL) proof-of-work cryptominer instead of lodash functionality. Consumers installing this package would unknowingly run a covert CPU/GPU miner on their systems.
npmCompromised packageTyposquatting - resolvedcritical
Malicious code in depcruise-wrap-stream-in-html (npm)
depcruise-wrap-stream-in-html@99.9.1 is a malicious npm package that mimics an internal helper of dependency-cruiser. It is a hollow package that downloads and executes arbitrary code from a Google Cloud Storage bucket during installation.
npmCompromised packageDependency confusionTyposquatting - resolvedcritical
Malicious code in wct-st (npm)
The npm package wct-st contained malicious code in its postinstall lifecycle script that collected and exfiltrated host identifiers to a remote endpoint. The package name resembles the deprecated web-component-tester, consistent with a typosquatting attack.
npmCompromised packageTyposquatting