Postinstall scripts are reviewed and safe
Why it matters
Postinstall scripts execute arbitrary shell code with your user's filesystem and network permissions the moment anyone runs npm install. This is the mechanism behind several real supply chain attacks — including the event-stream incident — where a legitimate package was transferred to a malicious maintainer who added a postinstall that harvested crypto wallets. OWASP A08 (Software and Data Integrity Failures) covers exactly this failure mode. CWE-829 (Inclusion of Functionality from Untrusted Control Sphere) and CWE-114 (Process Control) both apply when a package executes code you have not reviewed. SSDF PW.4 requires that third-party components be vetted. A postinstall script making network requests to an unrecognized host should be treated as a confirmed incident, not a warning.
Severity rationale
High because a malicious postinstall script executes with developer or CI system privileges at install time, before any code review occurs, and can exfiltrate secrets from the environment.
Remediation
Before installing any unfamiliar package with a lifecycle script, inspect its source:
# View the package tarball contents without installing
npm pack package-name --dry-run
# Or inspect the published source at:
# https://www.npmjs.com/package/package-name?activeTab=code
For CI environments where postinstall scripts from known-safe packages are the only expected hooks, add ignore-scripts=true to .npmrc and explicitly enable only those you've reviewed. Never allow a postinstall script that fetches from an external URL without a documented, reviewed justification.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Dependency & Supply Chain Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-829 — Inclusion of Functionality from Untrusted Control Sphere
- cwe · CWE-114 — Process Control
- owasp:2021 · A08 — Software and Data Integrity Failures
- ssdf:800-218 · PW.4 — Reuse Existing, Well-Secured Software
- soc2:2017 · CC6.8 — Prevention and detection of unauthorized or malicious software
Taxons
History
- 2026-04-18·v1.0.0·Initial import from dependency-supply-chain·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.8) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2