AAK-STARTUP-HOOK-NPM-INSTALL-001
npm lockfile entry with an install script in an MCP project
| Field | Value |
|---|---|
| Severity | LOW |
| Category | SUPPLY_CHAIN |
| Shipped | v0.6.28 |
| Scanner | agent_audit_kit/scanners/startup_hooks.py |
| OWASP MCP | MCP04:2025 (Software Supply Chain Attacks & Dependency Tampering) |
| OWASP Agentic | ASI04 (Agentic Supply Chain Vulnerabilities) |
What it catches
npm records "hasInstallScript": true on each package-lock.json entry whose
package has a preinstall, install or postinstall script. npm install and
npm ci run those scripts with the installing user's access, before any code of
the project runs: the npm counterpart of a Python startup hook, and the usual way
a malicious npm release runs. In a project that runs an MCP server, each such
entry is reported, so a new one shows up in review.
A project counts as an MCP project when its lockfile resolves
@modelcontextprotocol/sdk, @anthropic-ai/mcp or
@anthropic-ai/claude-agent-sdk, when a manifest beside it declares an MCP SDK,
or when an .mcp.json beside it declares a server.
What it does not catch
- What a script does: the rule reads the flag, not the script.
- lockfileVersion 1,
yarn.lockandpnpm-lock.yaml, which do not record install scripts.node_modulesis never walked and npm is never run. - A project whose
.npmrc, beside the lockfile, setsignore-scripts=trueis not reported. A--ignore-scriptspassed on a command line is not seen.
How to fix
Check that each listed package needs its script (native builds such as esbuild
and sharp do), then install with npm ci --ignore-scripts, or set
ignore-scripts=true in the project's .npmrc, and run the scripts you need
yourself with npm rebuild <package>.
Registry reference
This section is generated from the rule registry (agent_audit_kit/rules/builtin.py) when the documentation is built, so it follows the scanner. The rest of the page is hand-written; where the two disagree, the registry is what runs.
- Severity
- LOW
- Category
- Supply Chain (
supply-chain) - Scanner
agent_audit_kit/scanners/startup_hooks.py- Auto-fixable
- No.
- SARIF name
NpmInstallScriptInMcpProject
What it detects
A package-lock.json or npm-shrinkwrap.json entry is marked hasInstallScript: true in a project that runs an MCP server. npm install and npm ci run that package's preinstall, install or postinstall script on the machine that installs it, with the installing user's access, before any code of the server runs. That is the npm counterpart of a Python startup hook and the usual way a malicious npm release runs.
How to fix (registry)
Check that each listed package needs its install script (native builds such as esbuild and sharp do). Install with npm ci --ignore-scripts, or set ignore-scripts=true in the project's .npmrc, and run the scripts you need explicitly (npm rebuild <pkg>), so a new dependency cannot run code on install unseen.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-STARTUP-HOOK-NPM-INSTALL-001
Limitations
Reads package-lock.json and npm-shrinkwrap.json of lockfileVersion 2 or 3 outside AAK's skip directories, and reports each packages entry marked hasInstallScript: true, the project's own root entry excepted, when the project runs an MCP server: the lockfile resolves @modelcontextprotocol/sdk, @anthropic-ai/mcp or @anthropic-ai/claude-agent-sdk, a manifest beside it declares an MCP SDK, or an .mcp.json beside it declares a server. A lockfile whose directory has an .npmrc setting ignore-scripts=true is not reported. It reads the flag, not the script, so what a script does is not judged, and an --ignore-scripts passed on a command line, or an .npmrc elsewhere, is not seen. lockfileVersion 1, yarn.lock and pnpm-lock.yaml record no install scripts and are not read; node_modules is never walked and npm is never run. A lockfile over 32 MiB is not read.
References
- OWASP MCP Top 10: MCP04:2025 (Software Supply Chain Attacks & Dependency Tampering)
- OWASP Agentic Top 10: ASI04 (Agentic Supply Chain Vulnerabilities)
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-SUPPLY-05 (Dangerous Install Script)
- CSA AI Controls Matrix (AICM): STA-08