๐Ÿšจ Shai Hulud 2.0 Scanner

January 2, 2026 ยท View on GitHub

796+ npm packages compromised in November 2025. Is your project infected?

Fast, comprehensive scanner to detect the fastest-spreading npm supply chain attack ever observed. Scans for malicious files, stolen credentials, and automated worm propagation patterns.

License: MIT GitHub Issues GitHub Stars PRs Welcome

๐Ÿšจ About Shai Hulud 2.0

Shai Hulud 2.0 is one of the fastest-spreading npm supply chain attacks ever observed. The automated worm:

  • Hijacked 796+ unique npm packages (1,092+ total versions)
  • Stole credentials (npm tokens, GitHub tokens, cloud credentials)
  • Created malicious GitHub repositories
  • Exfiltrated secrets using TruffleHog
  • Spread automatically to maintainer's other packages

Timeline: Active November 2025 Vector: Stolen npm credentials โ†’ automated package hijacking โ†’ credential harvesting loop

โšก Quick Start (30 seconds)

# Download and run (no installation required)
curl -sSL https://raw.githubusercontent.com/nxgn-kd01/shai-hulud-scanner/main/scan.sh | bash -s /path/to/your/project

# Or clone and run
git clone https://github.com/nxgn-kd01/shai-hulud-scanner.git
cd shai-hulud-scanner
chmod +x scan.sh
./scan.sh /path/to/your/project

Results in seconds: ๐Ÿšจ Critical findings | โš ๏ธ Warnings | โœ… All clear

๐Ÿ“‹ What This Scanner Checks

This tool performs 8 comprehensive security checks:

1. Malicious File Detection ๐Ÿ”ด Critical

  • setup_bun.js - Malicious preinstall script
  • bun_environment.js - Obfuscated payload (6 known variants)

2. File Hash Verification ๐Ÿ”ด Critical

Validates files against known malicious SHA-256 hashes:

  • a3894003ad1d293ba96d77881ccd2071446dc3f65f434669b49b3da92421901a (setup_bun.js)
  • 6 known hashes for bun_environment.js variants

3. Lifecycle Script Analysis ๐ŸŸก Warning

  • Detects suspicious lifecycle scripts in package.json:
    • preinstall (highest risk - runs before npm install)
    • postinstall (runs after npm install)
    • install (runs during npm install)
    • prepare (runs after package is packed)
  • Identifies references to setup_bun or bun_environment
  • Flags unexpected script modifications

4. Compromised Package Ecosystems ๐ŸŸก Warning

Checks for packages from affected ecosystems:

  • @asyncapi/* (~60 compromised packages)
  • @voiceflow/* (~90 compromised packages)
  • posthog-* (~80 compromised packages)
  • @ensdomains/* (~40 compromised packages)
  • quickswap-* (~10 compromised packages)
  • zapier-* (~15 compromised packages)

5. TruffleHog Detection ๐ŸŸก Warning

  • Scans for TruffleHog secret scanning tool
  • Used by malware for credential harvesting

6. Recent Modifications Analysis ๐Ÿ”ต Info

  • Reviews package.json changes in last 30 days
  • Identifies suspicious patch version bumps
  • Helps spot unexpected modifications

7. GitHub Repository Patterns ๐ŸŸก Warning

  • Detects repos with description: "Sha1-Hulud: The Second Coming."
  • Identifies suspicious 18-character lowercase alphanumeric repo names
  • Flags unusual repository creation patterns

8. Package Lockfile Integrity ๐ŸŸก Warning

  • Checks for non-standard registry URLs in lockfiles
  • Detects git-based dependencies (potential supply chain risk)
  • Validates package-lock.json and yarn.lock integrity

๐Ÿš€ Getting Started

Prerequisites

Required:

  • macOS or Linux (Bash 4.0+)
  • find command (pre-installed)

Optional (recommended for full scanning):

  • git - For analyzing modification history
  • gh (GitHub CLI) - For scanning GitHub repositories
  • shasum or sha256sum - For file hash verification (usually pre-installed)

Step 1: Get the Scanner

Option A: Clone (Recommended for users)

# Clone the repository
git clone https://github.com/nxgn-kd01/shai-hulud-scanner.git
cd shai-hulud-scanner

# Make script executable
chmod +x scan.sh

Option B: Fork (Recommended for contributors)

# Fork on GitHub (click "Fork" button on repository page)
# Then clone your fork
git clone https://github.com/YOUR_USERNAME/shai-hulud-scanner.git
cd shai-hulud-scanner

# Make script executable
chmod +x scan.sh

# Add upstream remote to stay updated
git remote add upstream https://github.com/nxgn-kd01/shai-hulud-scanner.git

Option C: Quick Download (No git required)

# Download and run directly
curl -sSL https://raw.githubusercontent.com/nxgn-kd01/shai-hulud-scanner/main/scan.sh -o scan.sh
chmod +x scan.sh
./scan.sh /path/to/your/project

To scan your GitHub repositories for suspicious patterns, you'll need the GitHub CLI:

Install GitHub CLI:

# macOS
brew install gh

# Linux (Debian/Ubuntu)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

# Linux (RHEL/Fedora)
sudo dnf install gh

Authenticate with GitHub:

# Login to GitHub
gh auth login

# Follow the prompts:
# 1. Select "GitHub.com"
# 2. Select "HTTPS" or "SSH" (HTTPS recommended)
# 3. Select "Login with a web browser"
# 4. Copy the one-time code shown
# 5. Press Enter to open browser
# 6. Paste code and authorize

# Verify authentication
gh auth status

Step 3: Run Your First Scan

Scan a Local Project:

# Scan the current directory
./scan.sh

# Scan a specific project
./scan.sh /path/to/your/project

# Example: Scan your Node.js project
./scan.sh ~/code/my-app

Scan Multiple Projects:

# Scan all projects in a directory
for dir in ~/code/*/; do
    echo "===================="
    echo "Scanning: $(basename $dir)"
    echo "===================="
    ./scan.sh "$dir"
    echo ""
done

What Happens During a Scan:

  1. ๐Ÿ” Searches for malicious files (setup_bun.js, bun_environment.js)
  2. ๐Ÿ” Verifies file hashes against known malware
  3. ๐Ÿ“ฆ Checks package.json for suspicious scripts
  4. ๐ŸŒ Scans dependencies for compromised packages
  5. ๐Ÿ”จ Looks for TruffleHog secret scanner
  6. ๐Ÿ“… Analyzes recent package.json modifications
  7. ๐Ÿ™ Checks your GitHub repos for suspicious patterns (if gh authenticated)

Step 4: Review the Results

Console Output:

The scanner displays color-coded results:

  • ๐Ÿšจ RED (Critical) - Immediate action required, malware detected
  • โš ๏ธ YELLOW (Warning) - Suspicious patterns, review recommended
  • โœ… GREEN (Success) - Check passed, no issues
  • โ„น๏ธ BLUE (Info) - Informational findings

Detailed Report:

A full report is saved to shai-hulud-scan-report.txt in the current directory:

# View the report
cat shai-hulud-scan-report.txt

# Or open in your editor
code shai-hulud-scan-report.txt

Step 5: Scan Remote Repositories

Scan GitHub Repos Without Cloning:

# List your repos
gh repo list --limit 100

# Clone and scan a specific repo
gh repo clone YOUR_ORG/repo-name /tmp/scan-temp
./scan.sh /tmp/scan-temp
rm -rf /tmp/scan-temp

# Or create a helper script
cat > scan-remote.sh <<'EOF'
#!/bin/bash
REPO=\$1
TEMP_DIR=$(mktemp -d)
echo "Cloning $REPO to temporary directory..."
gh repo clone "$REPO" "$TEMP_DIR"
echo "Scanning..."
./scan.sh "$TEMP_DIR"
echo "Cleaning up..."
rm -rf "$TEMP_DIR"
EOF
chmod +x scan-remote.sh

# Use it:
./scan-remote.sh YOUR_USERNAME/repo-name

Common Issues & Solutions

Issue: "Permission denied"

# Make script executable
chmod +x scan.sh

Issue: "gh: command not found"

# Install GitHub CLI (see Step 2)
# Or skip GitHub repo scanning (other checks will still run)

Issue: "shasum: command not found"

# Install coreutils (usually pre-installed on macOS)
# Linux:
sudo apt-get install coreutils  # Debian/Ubuntu
sudo yum install coreutils       # RHEL/CentOS

# Or use sha256sum instead (scanner auto-detects)

Issue: Scan shows "INFO" items but you want details

# View the full report file
less shai-hulud-scan-report.txt

# Or use grep to find specific issues
grep -A 5 "WARNING\|CRITICAL" shai-hulud-scan-report.txt

๐Ÿ“– Usage

Basic Scan

Scan the current directory:

./scan.sh

Scan Specific Directory

./scan.sh /path/to/your/project

Scan Multiple Projects

# Scan all projects in a parent directory
for dir in /Users/username/code/*/; do
    echo "Scanning $dir"
    ./scan.sh "$dir"
done

JSON Output (v1.1.0+)

For automation and SIEM integration:

# Get JSON output
./scan.sh /path/to/project --json

# Pipe to jq for processing
./scan.sh /path/to/project --json | jq '.summary'

# Save results
./scan.sh /path/to/project --json > scan-results.json

Example JSON output:

{
  "scanner": "shai-hulud-scanner",
  "version": "1.1.0",
  "scanDate": "2025-01-02T12:00:00Z",
  "scanDirectory": "/path/to/project",
  "summary": {
    "critical": 0,
    "warning": 1,
    "info": 2
  },
  "findings": [
    {
      "severity": "warning",
      "category": "scripts",
      "message": "postinstall script found",
      "file": "/path/to/project/package.json"
    }
  ],
  "references": [...]
}

CI/CD Integration

Quick Integration:

name: Security Scan

on: [push, pull_request]

jobs:
  shai-hulud-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Run Shai Hulud Scanner
        run: |
          curl -sSL https://raw.githubusercontent.com/nxgn-kd01/shai-hulud-scanner/main/scan.sh | bash -s .

Full Example Workflow:

See examples/github-actions-workflow.yml for a complete workflow with:

  • Artifact uploads
  • PR comments with scan results
  • Automatic issue creation on detection
  • Scheduled daily scans

๐Ÿ“Š Output

Console Output

The scanner provides color-coded results:

  • ๐Ÿšจ RED (Critical): Immediate action required
  • โš ๏ธ YELLOW (Warning): Review recommended
  • โœ… GREEN (Success): Check passed
  • โ„น๏ธ BLUE (Info): Informational findings

Report File

A detailed report is saved to shai-hulud-scan-report.txt containing:

  • Scan metadata (date, directory, version)
  • Detailed findings for each check
  • Recommended actions if issues found
  • References to security resources

Exit Codes

  • 0 - No issues found or warnings only
  • 1 - Critical issues detected

๐ŸŽฏ Example Output

=== Shai Hulud 2.0 Scanner v1.1.0 ===
Scanning directory: /Users/username/project

=== 1. Scanning for Malicious Files ===
โœ… No malicious files found

=== 2. Checking File Hashes ===
โœ… No known malicious file hashes detected

=== 3. Checking package.json for Suspicious Scripts ===
โœ… No suspicious scripts found

=== 4. Checking for Compromised Package Ecosystems ===
โœ… No packages from compromised ecosystems found

=== 5. Scanning for TruffleHog ===
โœ… No TruffleHog installations found

=== 6. Analyzing Recent package.json Changes ===
โœ… No recent package.json modifications

=== 7. Checking GitHub Repository Patterns ===
โœ… No suspicious repository descriptions
โœ… No suspicious repository names

=== 8. Checking Package Lockfile Integrity ===
โœ… Lockfile integrity checks passed

=== Scan Summary ===

Critical Issues: 0
Warnings: 0
Info Items: 0

โœ… All clear! No indicators of compromise found.
โ„น๏ธ  Detailed report saved to: shai-hulud-scan-report.txt

๐Ÿ”ง Troubleshooting

"shasum: command not found"

Install shasum (usually part of coreutils):

# macOS (built-in)
# Linux
sudo apt-get install coreutils  # Debian/Ubuntu
sudo yum install coreutils       # RHEL/CentOS

"gh: command not found"

Install GitHub CLI:

# macOS
brew install gh

# Linux
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

# Authenticate
gh auth login

๐Ÿ›ก๏ธ What To Do If Compromise Is Detected

โš ๏ธ CRITICAL: If the scanner detects issues, follow our comprehensive remediation guide immediately.

๐Ÿ“– Complete Incident Response Guide

Read the full guide: REMEDIATION.md

The guide includes:

  • โœ… Immediate response steps (first 15 minutes)
  • โœ… Complete credential rotation procedures (npm, GitHub, AWS, GCP, Azure, etc.)
  • โœ… Code cleanup instructions
  • โœ… Investigation and forensics procedures
  • โœ… Disclosure and reporting requirements
  • โœ… Post-incident hardening measures
  • โœ… Recovery checklist

Quick Response (First 15 Minutes)

  1. Isolate Affected Systems

    # Stop deployments immediately
    # Move compromised code to quarantine
    mkdir ~/quarantine-$(date +%Y%m%d)
    mv /path/to/compromised-project ~/quarantine-$(date +%Y%m%d)/
    
  2. Rotate ALL Credentials Immediately

    # npm tokens
    npm token revoke --all
    
    # GitHub tokens
    gh auth logout && gh auth login
    
    # AWS/GCP/Azure - see REMEDIATION.md for full instructions
    
  3. Remove Malicious Code

    find . -name "setup_bun.js" -delete
    find . -name "bun_environment.js" -delete
    git add -A && git commit -m "SECURITY: Remove malicious files"
    
  4. Report the Incident

  5. Follow Complete Guide

    • See REMEDIATION.md for detailed step-by-step instructions
    • Use the recovery checklist to track progress
    • Document everything for post-mortem

For Warnings

If you get warnings (not critical issues):

  1. Review the scan report

    cat shai-hulud-scan-report.txt
    
  2. Verify legitimacy of flagged items

  3. Update dependencies if needed: npm audit && npm update

  4. Re-run scanner to confirm: ./scan.sh .

Need Help?

๐Ÿ“š Resources

Official IOC Sources

Community Tools

Shai Hulud 2.0 Detection:

Related Vulnerability Scanners:

  • react2shell-scanner - Detect CVE-2025-55182 (React2Shell) RCE vulnerability in React Server Components

Security Best Practices

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit your changes (git commit -m 'Add new detection')
  4. Push to the branch (git push origin feature/improvement)
  5. Open a Pull Request

Ideas for Contributions

  • Add support for additional IOC sources
  • Implement JSON output format (v1.1.0)
  • Add lockfile integrity checks (v1.1.0)
  • Detect all lifecycle scripts (v1.1.0)
  • Add Docker container support
  • Create npm package version
  • Add integration tests
  • Support for other package managers (pip, cargo, etc.)

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

โš ๏ธ Disclaimer

This tool is provided "as is" for security research and defensive purposes only. While we make every effort to keep the IOC list current, new variants may emerge. Always:

  • Keep the scanner updated
  • Follow official security advisories
  • Report suspected compromises to npm security
  • Maintain defense-in-depth security practices

๐Ÿ™ Acknowledgments

  • DataDog Security Labs for comprehensive IOC research and analysis
  • npm Security Team for rapid response
  • Community security researchers: Koi.ai, StepSecurity, ReversingLabs, HelixGuard, SocketDev, Wiz

๐Ÿ“ž Support


Stay Safe! ๐Ÿ›ก๏ธ

Remember to run this scanner:

  • โœ… Before npm install operations
  • โœ… Before merging dependency updates
  • โœ… Regularly in CI/CD pipelines
  • โœ… After inheriting or acquiring projects