How to Check if a GitHub Repo or npm Package Is Safe Before Running npm install
Fake technical-interview repositories, typosquatted npm utilities, and hijacked maintainer accounts have become the #1 way attackers steal developer .env secrets, SSH keys, browser cookies, and AI coding keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, AWS, and Stripe tokens). As documented in our November 2026 GitHub Supply-Chain Advisory, modern payloads execute silently during npm install or the instant you open a folder in VS Code or Cursor — long before you ever run npm run dev.
github.com/owner/repo URL into our free online scanner to inspect postinstall hooks, obfuscated scripts, and MCP configs without cloning.
1. The Five Files Attackers Weaponize in Untrusted Repos
Before cloning or installing dependencies from an unfamiliar repository, inspect these five execution vectors remotely via the GitHub web UI or API:
package.jsonlifecycle hooks (preinstall,install,postinstall,prepare): npm, pnpm, and Yarn automatically run shell commands defined in these fields unless script execution is explicitly disabled..vscode/tasks.jsonwith"runOn": "folderOpen": Simply opening a malicious repository folder in VS Code or Cursor can trigger an automatic background shell command if you click "Trust Workspace."- Workspace MCP manifests (
.mcp.json,.cursor/mcp.json,.vscode/mcp.json): Rogue Model Context Protocol definitions can spin up arbitrary local `npx` or `python` processes with access to your filesystem and environment variables. See our MCP & Claude Code Hardening Guide. - Obfuscated single-line JavaScript files: Look for gigantic horizontal whitespace padding (400+ spaces hiding `eval(atob(...))` off-screen), hex-encoded byte arrays (`_0x...`), or dynamic `child_process.execSync` calls inside `vite.config.js`, `next.config.js`, or `webpack.config.js`.
setup.py/pyproject.tomlcustom build hooks: In Python repositories, `pip install -e .` executes arbitrary code inside `setup.py`.
2. Safe CLI Commands to Audit an npm Package or Repo Without Executing It
Never run bare npm install on untrusted code. Use these read-only terminal commands first:
# 1. Inspect an npm package's scripts remotely without downloading or installing
npm view <package-name> scripts dependencies maintainers
# 2. Download the tarball only and list every file inside it safely
npm pack <package-name>
tar -ztvf <package-name>-*.tgz
# 3. Install dependencies with ALL preinstall/postinstall hooks blocked
npm install --ignore-scripts
# 4. Make --ignore-scripts your safe global workstation default
npm config set ignore-scripts true
If you have already cloned a repository locally (without opening it in an IDE), scan for high-risk shell and credential-exfiltration patterns before trusting it:
# Check for hidden VS Code auto-run tasks, MCP servers, and lifecycle hooks
grep -RInE "(postinstall|preinstall|folderOpen|child_process|Buffer\.from\(.*base64|\.env|\.ssh|claude\.json)" .
3. Red Flags That Signal a Supply-Chain Credential Stealer
- Fake commit history or brand-new repo with inflated stars: Attackers bot-star repositories to 200–1,000 stars overnight while commit author emails don't match actual GitHub profiles.
- External binary or script fetches in build configs: Any reference to raw IP addresses, `pastebin`, `ngrok`, `trycloudflare.com`, Discord webhooks, or Telegram bot APIs inside `scripts/` or config files.
- Reads targeting AI & Cloud credential paths: Access to `~/.claude.json`, `~/.cursor/`, `~/.aws/credentials`, `~/.ssh/id_ed25519`, `~/.npmrc`, or recursive `.env` file harvesting.
4. Automate Real-Time Workstation Protection
Manual checks work when reviewing one repository, but AI coding agents like Claude Code, Cursor, Windsurf, and Cline routinely install packages and invoke MCP tools autonomously. ClaudeArmor Desktop sits between your coding agents and your OS — blocking poisoned postinstall scripts, quarantining obfuscated payloads, and tripwiring your .env and cloud keys in real time.
Try the Free Online GitHub & MCP Scanner → or explore Workstation Defense Passes (from $27) →
Frequently Asked Questions
Can cloning a GitHub repository infect my computer before I run the code?
Cloning with plain git clone only writes files, unless malicious Git hooks/submodules are exploited on unpatched Git versions. However, opening the folder in VS Code/Cursor (.vscode/tasks.json with runOn: folderOpen) or running npm install executes attacker code immediately.
How do I install npm packages without running malicious postinstall scripts?
Pass npm install --ignore-scripts (or set ignore-scripts=true in ~/.npmrc) so preinstall, install, and postinstall shell hooks cannot run automatically, and audit the repository first at claudearmorsec.com/workbench.html.
What files should I inspect first when checking if a GitHub repo is safe?
Check package.json scripts, .vscode/tasks.json, .cursor/mcp.json, .mcp.json, vite.config.js / next.config.js, and hidden .github/workflows or .ci-*.sh scripts for base64 decoding, outbound network calls, or .env / ~/.ssh reads.