HomeFree ScannerDocsPricingBlogDownload

How to Check if a GitHub Repo or npm Package Is Safe Before Running npm install

By ClaudeArmor Security Research • Updated November 30, 2026 • 9 min technical guide

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.

⚡ Need an Instant Verdict on a GitHub URL? Paste any github.com/owner/repo URL into our free online scanner to inspect postinstall hooks, obfuscated scripts, and MCP configs without cloning.
Scan a GitHub Repo Free →

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:

  1. package.json lifecycle hooks (preinstall, install, postinstall, prepare): npm, pnpm, and Yarn automatically run shell commands defined in these fields unless script execution is explicitly disabled.
  2. .vscode/tasks.json with "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."
  3. 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.
  4. 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`.
  5. setup.py / pyproject.toml custom 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

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.