# Core tooling
-weight: 500;">npm audit --audit-level=moderate
npx better--weight: 500;">npm-audit
npx socket scan . # Deeper static checks
npx lockfile-lint --path package-lock.json --type -weight: 500;">npm
npx installed-check
# Core tooling
-weight: 500;">npm audit --audit-level=moderate
npx better--weight: 500;">npm-audit
npx socket scan . # Deeper static checks
npx lockfile-lint --path package-lock.json --type -weight: 500;">npm
npx installed-check
# Core tooling
-weight: 500;">npm audit --audit-level=moderate
npx better--weight: 500;">npm-audit
npx socket scan . # Deeper static checks
npx lockfile-lint --path package-lock.json --type -weight: 500;">npm
npx installed-check
import subprocess, json
import anthropic def get_install_scripts(package_name: str) -> dict: result = subprocess.run( ["-weight: 500;">npm", "view", package_name, "--json"], capture_output=True, text=True ) data = json.loads(result.stdout) return { "name": data.get("name"), "scripts": data.get("scripts", {}), "maintainers": data.get("maintainers", []), "versions": list(data.get("time", {}).keys())[-5:], "repository": data.get("repository", {}) } def audit_package(meta: dict) -> str: client = anthropic.Anthropic() prompt = f"""
You are a supply chain security analyst. Audit this -weight: 500;">npm package metadata for red flags: {json.dumps(meta, indent=2)} Check for:
- Suspicious postinstall/preinstall scripts
- Mismatched repository URLs
- Very recent maintainer changes
- Version bumps with no -weight: 500;">git activity
- Scripts that reference -weight: 500;">curl, -weight: 500;">wget, eval, or exec
- Obfuscated code indicators Return a risk rating (LOW/MEDIUM/HIGH) and specific concerns. Be concise.
""" message = client.messages.create( model="claude-opus-4-7", max_tokens=512, messages=[{"role": "user", "content": prompt}] ) return message.content[0].text # Run against all direct dependencies
with open("package.json") as f: deps = json.load(f).get("dependencies", {}) for pkg in deps: meta = get_install_scripts(pkg) result = audit_package(meta) if "HIGH" in result: print(f"🚨 {pkg}: {result}")
import subprocess, json
import anthropic def get_install_scripts(package_name: str) -> dict: result = subprocess.run( ["-weight: 500;">npm", "view", package_name, "--json"], capture_output=True, text=True ) data = json.loads(result.stdout) return { "name": data.get("name"), "scripts": data.get("scripts", {}), "maintainers": data.get("maintainers", []), "versions": list(data.get("time", {}).keys())[-5:], "repository": data.get("repository", {}) } def audit_package(meta: dict) -> str: client = anthropic.Anthropic() prompt = f"""
You are a supply chain security analyst. Audit this -weight: 500;">npm package metadata for red flags: {json.dumps(meta, indent=2)} Check for:
- Suspicious postinstall/preinstall scripts
- Mismatched repository URLs
- Very recent maintainer changes
- Version bumps with no -weight: 500;">git activity
- Scripts that reference -weight: 500;">curl, -weight: 500;">wget, eval, or exec
- Obfuscated code indicators Return a risk rating (LOW/MEDIUM/HIGH) and specific concerns. Be concise.
""" message = client.messages.create( model="claude-opus-4-7", max_tokens=512, messages=[{"role": "user", "content": prompt}] ) return message.content[0].text # Run against all direct dependencies
with open("package.json") as f: deps = json.load(f).get("dependencies", {}) for pkg in deps: meta = get_install_scripts(pkg) result = audit_package(meta) if "HIGH" in result: print(f"🚨 {pkg}: {result}")
import subprocess, json
import anthropic def get_install_scripts(package_name: str) -> dict: result = subprocess.run( ["-weight: 500;">npm", "view", package_name, "--json"], capture_output=True, text=True ) data = json.loads(result.stdout) return { "name": data.get("name"), "scripts": data.get("scripts", {}), "maintainers": data.get("maintainers", []), "versions": list(data.get("time", {}).keys())[-5:], "repository": data.get("repository", {}) } def audit_package(meta: dict) -> str: client = anthropic.Anthropic() prompt = f"""
You are a supply chain security analyst. Audit this -weight: 500;">npm package metadata for red flags: {json.dumps(meta, indent=2)} Check for:
- Suspicious postinstall/preinstall scripts
- Mismatched repository URLs
- Very recent maintainer changes
- Version bumps with no -weight: 500;">git activity
- Scripts that reference -weight: 500;">curl, -weight: 500;">wget, eval, or exec
- Obfuscated code indicators Return a risk rating (LOW/MEDIUM/HIGH) and specific concerns. Be concise.
""" message = client.messages.create( model="claude-opus-4-7", max_tokens=512, messages=[{"role": "user", "content": prompt}] ) return message.content[0].text # Run against all direct dependencies
with open("package.json") as f: deps = json.load(f).get("dependencies", {}) for pkg in deps: meta = get_install_scripts(pkg) result = audit_package(meta) if "HIGH" in result: print(f"🚨 {pkg}: {result}")
name: Supply Chain Audit
on: [pull_request] jobs: audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: -weight: 500;">pip -weight: 500;">install anthropic - run: -weight: 500;">npm audit --audit-level=high - run: npx socket scan . --strict - name: LLM Dependency Audit env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: python scripts/llm_audit.py continue-on-error: false
name: Supply Chain Audit
on: [pull_request] jobs: audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: -weight: 500;">pip -weight: 500;">install anthropic - run: -weight: 500;">npm audit --audit-level=high - run: npx socket scan . --strict - name: LLM Dependency Audit env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: python scripts/llm_audit.py continue-on-error: false
name: Supply Chain Audit
on: [pull_request] jobs: audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: -weight: 500;">pip -weight: 500;">install anthropic - run: -weight: 500;">npm audit --audit-level=high - run: npx socket scan . --strict - name: LLM Dependency Audit env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: python scripts/llm_audit.py continue-on-error: false - Typosquatting: lodahs instead of lodash, expres instead of express
- Dependency confusion: publishing a private package name to the public registry
- Maintainer account takeover: injecting malicious code into a legitimate package's release
- Protestware: maintainers embedding political payloads (remember colors and faker?) - Subscribe to supply chain incident feeds — Socket.dev's blog, OpenSSF's advisories, and the OSSF Malicious Packages repository on GitHub all publish real incident data.
- Update your audit prompt quarterly — as new attack patterns emerge (like recently popularized GitHub Actions poisoning), add them explicitly to the LLM prompt.
- Lock your lockfile — commit package-lock.json or pnpm-lock.yaml and fail CI if it drifts unexpectedly. Lockfile tampering is a common vector.
- Pin major versions, automate patch updates with audit gates — use Renovate or Dependabot, but gate every auto-merge on the audit workflow passing.
- Audit your audit tools — yes, seriously. The tools you use to audit dependencies are themselves dependencies. Socket, Snyk, and similar tools should be pinned and reviewed on the same cadence.