Skip to content

AAK-SUPPLY-003: Dependency uses install scripts

Severity
MEDIUM
Category
Supply Chain (supply-chain)
Scanner
agent_audit_kit/scanners/supply_chain.py
Auto-fixable
No.
SARIF name
DangerousInstallScripts

What it detects

package.json has install scripts (preinstall, postinstall, etc.) that execute arbitrary commands during npm install.

How to fix

Audit install scripts. Use --ignore-scripts flag and run scripts manually after review.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-SUPPLY-003

Limitations

Reads the preinstall, install, postinstall and prepare scripts of the root package.json only, and reports one that names the whole word curl, wget, fetch, nc, ncat, ssh, http, https, axios or request, or that runs a command, anywhere in a chain or in a command substitution ($(...), backticks), whose program, after any variable assignments, is not node, node-gyp, node-gyp-build, ts-node, tsx, vite-node, tsc, webpack, rollup, esbuild or vite (by name, so node_modules/.bin/tsc passes), unless the command is npm run build or npm run build:<name> (not npm run build-and-setup). node-pre-gyp and prebuild-install are reported: they download a prebuilt binary from a host the package.json names. A command after the first that runs nothing (|| true, && echo done) is not judged unless it redirects into a file, though a substitution in its arguments is. A launcher is judged by the package it runs: npx, npm exec and bunx pass one the package.json declares, or a build tool from that list, named bare or with a registry version, because they run it from node_modules; anything else is reported as fetched at install time, including a git, alias or tag spec of a declared package (husky@github:org/repo, husky@npm:other, husky@latest) and a declared package's command under another name (npx playwright with only @playwright/test declared). When an option names the package (npx -p pkg cmd), the command it runs is judged too, unless it is the package's own. Neither the code a node, ts-node, tsx or vite-node command runs nor the script npm run build or npm run build:<name> runs is looked into, so node -e "require('child_process').execSync('sh ./scripts/setup.sh')" passes, and so does npm run build:css whatever that script runs. An arithmetic expansion ($((1+2))) is read as a command substitution, so its expression is judged as a command. A substitution nested more than four deep, and a script over 4,096 characters, is reported without being read. The install scripts of dependencies (a lockfile entry marked hasInstallScript) and of a workspace package.json in a sub-directory are not read. A package.json over 2 MB is not read.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-SUPPLY-003.md: the page then shows that text, with the registry reference appended under it.