UNPKG

shai-hulud-inspector

Version:

Security scanner that checks npm dependencies for Shai Hulud vulnerable packages. 100% offline, zero data collection, zero telemetry. Scans all dependencies against 689+ known compromised packages.

264 lines (179 loc) • 8.3 kB
# Shai Hulud Inspector šŸŖ±šŸ” A security scanner that checks your npm dependencies against the Shai Hulud vulnerable packages database. This tool helps identify if your project contains any of the ~1000+ packages compromised in the Shai Hulud supply chain attack. ## Quick Start ```bash npx shai-hulud-inspector@latest ``` That's it! No installation required. The scanner will check your project for vulnerabilities. ## What is Shai Hulud? Shai Hulud is a sophisticated worm that spread through over 1,000 npm packages, named after the sandworms from the Dune universe. This attack represents one of the largest supply chain attacks targeting the npm ecosystem. ## Features - šŸ” Scans all dependencies and transitive dependencies - šŸ“Š Checks against a database of 798+ known vulnerable packages - šŸŽÆ Identifies exact version matches - šŸ“‹ **Smart Fallback** - Works with package-lock.json OR package.json - šŸ“ Clear, actionable reporting - ⚔ Fast and lightweight - šŸ”’ Works offline (no external API calls) - šŸ›”ļø **100% Private - Zero data collection, zero telemetry, zero metrics** ## Installation ### Quick Start - No Installation Required! ⚔ Run instantly with npx (always uses latest version): ```bash npx shai-hulud-inspector@latest ``` ### Install Globally (Optional) ```bash npm install -g shai-hulud-inspector ``` ### Or clone and use locally ```bash git clone https://github.com/Superkunair/shai-hulud-inspector.git cd shai-hulud-inspector npm install npm start ``` ## Usage ### Quick Start - Run with npx (Recommended) ⚔ **Scan your current project:** ```bash npx shai-hulud-inspector@latest ``` **Scan a specific project:** ```bash npx shai-hulud-inspector@latest /path/to/your/project ``` **Why use npx @latest?** - āœ… No installation required - āœ… Always uses the newest version - āœ… Latest vulnerability database - āœ… Perfect for CI/CD pipelines ### Alternative Methods **If installed globally:** ```bash shai-hulud-inspector shai-hulud-inspector /path/to/your/project ``` **From cloned repository:** ```bash npm start npm start -- /path/to/your/project ``` ### šŸ“‹ Dependency Scanning Modes The scanner operates in two modes depending on what files it finds: | Mode | File | Scans | Protection Level | |------|------|-------|------------------| | **Complete** āœ… | `package-lock.json` | Direct + Transitive dependencies | **Full Protection** | | **Limited** āš ļø | `package.json` only | Direct dependencies only | **Partial Protection** | **āš ļø IMPORTANT:** Without `package-lock.json`, transitive dependencies (dependencies of your dependencies) are NOT scanned. This means hidden malicious packages could be missed! **To generate package-lock.json:** ```bash npm install ``` šŸ‘‰ **Learn more:** See [TRANSITIVE_DEPENDENCIES.md](TRANSITIVE_DEPENDENCIES.md) for why this matters ### Example Output ``` šŸ”Ž Scanning project at: /Users/username/my-project ╔═══════════════════════════════════════════════════════════════╗ ā•‘ SHAI HULUD VULNERABILITY SCANNER ā•‘ ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā• šŸ“¦ Total packages scanned: 458 šŸ” Known vulnerable packages in database: 690 āš ļø Vulnerable packages found: 2 ā›” VULNERABLE PACKAGES DETECTED: ═══════════════════════════════════════════════════════════════ 1. Package: @posthog/icons ā”œā”€ Installed version(s): 0.36.1 ā”œā”€ Vulnerable version(s): 0.36.1 └─ āš ļø ACTION REQUIRED: Remove or update this package immediately! 2. Package: posthog-js ā”œā”€ Installed version(s): 1.297.3 ā”œā”€ Vulnerable version(s): 1.297.3 └─ āš ļø ACTION REQUIRED: Remove or update this package immediately! ═══════════════════════════════════════════════════════════════ šŸ”— More info: https://www.bleepingcomputer.com/news/security/shai-hulud-worm-spreads-via-1000-npm-packages ⚔ Recommendation: Run "npm audit" and update/remove vulnerable packages. ``` ## How It Works 1. **Dependency Extraction**: Reads your `package-lock.json` to extract all dependencies and transitive dependencies 2. **Version Matching**: Compares installed packages against the Shai Hulud vulnerable packages database 3. **Report Generation**: Displays a detailed report of any matches found ## Exit Codes The scanner returns standard exit codes for easy CI/CD integration: - **Exit Code 0**: āœ… No vulnerabilities found (Success) - **Exit Code 1**: āŒ Vulnerabilities detected or error occurred (Failure) The exit code is displayed at the end of each scan for transparency. ### CI/CD Integration Use the exit code to fail builds when vulnerabilities are detected: ```bash # In your CI pipeline (always use latest version) npx shai-hulud-inspector@latest || exit 1 # Or if installed globally shai-hulud-inspector || exit 1 # Check exit code explicitly npx shai-hulud-inspector@latest if [ $? -ne 0 ]; then echo "Build failed due to security vulnerabilities" exit 1 fi ``` **šŸ“ Ready-to-use CI/CD Examples:** We provide production-ready configuration files for: - āœ… GitHub Actions - āœ… AWS CodeBuild - āœ… Azure Pipelines - āœ… Google Cloud Build **[šŸ“– View CI/CD Examples →](examples/ci-cd/README.md)** ## Vulnerable Packages Database The scanner checks against a curated list of 690+ packages identified in the Shai Hulud attack, stored in `artifacts/node/shai-hulud-2-packages.json`. This includes packages from various scopes including: - @posthog/* - @ensdomains/* - @voiceflow/* - @browserbasehq/* - And many more... ## Requirements - Node.js >= 14.0.0 - A project with `package-lock.json` file ## Testing Run the included tests: ```bash npm test ``` ## Contributing Found a vulnerable package not in the database? Please open an issue or submit a pull request with the package details. ## Limitations - Requires `package-lock.json` (npm projects) - Only checks exact version matches - Does not scan `yarn.lock` or `pnpm-lock.yaml` (yet) ## Privacy & Security Notes ### šŸ”’ Privacy First **This tool respects your privacy:** - āœ… **No data collection** - We don't collect any information about your projects - āœ… **No telemetry** - No usage statistics or analytics - āœ… **No metrics** - No tracking of any kind - āœ… **Completely offline** - All scanning happens locally on your machine - āœ… **No external API calls** - Your code and dependencies stay private - āœ… **Open source** - Audit the code yourself at [GitHub](https://github.com/Superkunair/shai-hulud-inspector) ### āš ļø Security Scope **Important**: This tool checks against a specific list of known vulnerable packages from the Shai Hulud attack. It does NOT: - Replace comprehensive security tools like `npm audit` - Check for other types of vulnerabilities - Provide vulnerability fixes Always use multiple security tools and keep your dependencies up to date. ## Resources ### Documentation - [CI/CD Examples](examples/ci-cd/README.md) - Production-ready configs for GitHub Actions, AWS, Azure, GCP - [Transitive Dependencies](TRANSITIVE_DEPENDENCIES.md) - **Why package-lock.json matters for security** - [Exit Codes Reference](EXIT_CODES.md) - Complete guide to exit codes and CI/CD integration - [Privacy Policy](PRIVACY.md) - Our zero data collection commitment - [How It Works](HOW_IT_WORKS.md) - Technical explanation of the matching algorithm - [Usage Examples](USAGE_EXAMPLES.md) - Comprehensive usage scenarios ### External Links - [Bleeping Computer Article](https://www.bleepingcomputer.com/news/security/shai-hulud-worm-spreads-via-1000-npm-packages) - [npm Security Best Practices](https://docs.npmjs.com/security-best-practices) ## License ISC ## Author Jordan Axel Hernandez Mercado --- **Stay safe and keep your dependencies clean!**