[RRFC] allowScripts Review Report
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, nodejs
Direzione di ricerca
Inizia dal comportamento attuale di npm approve-scripts --allow-scripts-pending e dalla documentazione npm collegata, quindi esamina il Markdown proposto e i campi del report JSON, i segnali di rischio e gli obiettivi non inclusi. Il lavoro è completato quando l’RFC definisce in modo sufficientemente chiaro il formato e l’ambito del report da consentire un piano di implementazione senza eseguire o approvare automaticamente gli script del ciclo di vita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Motivation ("The Why")
npm v12’s allowScripts model is a strong supply-chain security improvement because it prevents dependency lifecycle scripts from running automatically without approval.
However, the approval step becomes the new trust boundary.
Approving an entry in allowScripts is not ordinary package metadata. It grants install-time code execution permission to a package artifact. That code may run on developer machines and CI/CD runners, where it could potentially access source code, npm tokens, GitHub tokens, CI variables, cloud/OIDC identities, build artifacts, or publishing permissions.
This matters because of active Shai-Hulud / Mini Shai-Hulud-style supply-chain attacks. These are worm-like npm compromise patterns where malicious package versions or compromised maintainer accounts use install-time execution paths to steal credentials, publish additional compromised packages, and spread through trusted package/update workflows.
npm approve-scripts --allow-scripts-pending helps identify packages that need script approval, but the current review experience still leaves the developer with the harder question:
What exactly am I approving?
For example, if a pending lifecycle script is:
{
"postinstall": "node install.js"
}
the reviewer can see the lifecycle command, but not what install.js does, what files it imports, whether it shells out, whether it makes network calls, whether it reads credentials from process.env, or whether it writes outside the package directory.
That creates an approval-fatigue risk. Developers may see repeated pending approvals, especially from transitive dependencies, and eventually approve packages reflexively just to get installs or CI builds moving.
A review-report mode would make approval more deliberate, auditable, and useful for humans, CI systems, dependency bots, and AI-assisted security review.
Example
A command like this:
npm approve-scripts --allow-scripts-pending --format=review-markdown > npm-script-review.md
or:
npm approve-scripts --allow-scripts-pending --format=review-json > npm-script-review.json
could generate review evidence for each pending package.
Example markdown-style output:
# npm Lifecycle Script Approval Review
## Package: [email protected]
Location: ./node_modules/x/
Dependency type: transitive
Introduced by:
- app -> [email protected] -> [email protected]
Approval status:
- pending
- not covered by allowScripts
Lifecycle scripts:
```json
{
"install": "node install.js",
"postinstall": "node setup.js"
}
```
Referenced files:
### ./install.js
Reason included:
- referenced by lifecycle script: `install`
Detected signals:
- imports `./lib/download.js`
- reads `process.env`
- uses `child_process`
- performs network request
### ./setup.js
Reason included:
- referenced by lifecycle script: `postinstall`
Detected signals:
- writes files under package directory
### ./lib/download.js
Reason included:
- required by `install.js`
Detected signals:
- performs HTTPS request
- references external URL
- no obvious integrity check detected
Risk summary:
- network access detected
- child process usage detected
- environment variable access detected
Suggested review focus:
- confirm what remote artifact is downloaded
- confirm whether downloaded artifact is pinned or verified
- confirm whether environment variable access could expose credentials
- confirm whether child process execution is constrained
Example JSON-style output:
{
"packages": [
{
"name": "x",
"version": "1.3.4",
"location": "./node_modules/x",
"approvalStatus": "pending",
"dependencyType": "transitive",
"introducedBy": [
["app", "[email protected]", "[email protected]"]
],
"lifecycleScripts": {
"install": "node install.js",
"postinstall": "node setup.js"
},
"referencedFiles": [
{
"path": "./install.js",
"reason": "referenced by install script",
"sha256": "example-hash",
"signals": [
"requires-local-file",
"uses-child-process",
"reads-process-env",
"network-access"
],
"references": [
"./lib/download.js"
]
},
{
"path": "./setup.js",
"reason": "referenced by postinstall script",
"sha256": "example-hash",
"signals": [
"writes-file"
],
"references": []
},
{
"path": "./lib/download.js",
"reason": "required by ./install.js",
"sha256": "example-hash",
"signals": [
"network-access",
"external-url"
],
"references": []
}
],
"changeClassification": {
"status": "script-changed-since-last-approved-version",
"previousApprovedVersion": "1.3.3"
}
}
]
}
This would let CI, Dependabot, or other dependency automation say:
This package has pending install-time lifecycle code. Here is the review report.
Importantly, the tool would not approve anything automatically.
A human could review the report and then submit a separate commit updating allowScripts or denyScripts, if appropriate.
This also supports AI-assisted review safely. For example, a developer or CI job could generate the JSON report and ask an AI/security-review agent:
Review npm-script-review.json for install-time security concerns.
For each pending package:
- summarize what lifecycle code would run
- identify referenced files that should be reviewed
- flag use of child_process, shell execution, eval, dynamic import, obfuscation, network calls, remote downloads, process.env access, credential/token references, writes outside the package directory, or modification of npm/git/ssh/shell config
- identify whether the script is new, changed, or unchanged from the previously approved version
- call out transitive dependency paths and which direct dependency introduced the package
- recommend approve, deny, or needs-human-review, with reasoning
- do not modify allowScripts or denyScripts
- do not run the lifecycle scripts
The key distinction is that AI can help review the bounded report, but it should not be the actor that grants approval.
How
Current Behaviour
npm approve-scripts --allow-scripts-pending identifies packages whose lifecycle scripts are not yet covered by allowScripts.
From the discussion around the npm v12 changes, the pending output can show the lifecycle script value from package.json.
That is useful, but it does not fully support review.
For example:
{
"postinstall": "node install.js"
}
The reviewer still has to manually inspect install.js, trace local require() / import calls, find any referenced shell scripts or binaries, and look for risky behavior.
This is especially difficult when the package is a transitive dependency that the project team does not directly know or maintain.
The current flow also does not appear to distinguish clearly between different risk levels, such as:
[new lifecycle script]
[lifecycle script changed since last approved version]
[lifecycle script unchanged since last approved version]
[new referenced file]
[referenced file changed since last approved version]
A routine version bump where the lifecycle script is unchanged is very different from a package that newly adds postinstall. Those should not look identical in the pending approval workflow.
Desired Behaviour
Add a first-class review-report mode for pending lifecycle script approvals.
Possible command shapes:
npm approve-scripts --allow-scripts-pending --format=review-markdown
npm approve-scripts --allow-scripts-pending --format=review-json
or:
npm approve-scripts --allow-scripts-pending --review-report npm-script-review.md
npm approve-scripts --allow-scripts-pending --review-report-json npm-script-review.json
The exact option names are not the important part. The important part is having stable human-readable and machine-readable output that does not require scraping console text.
The report should be best-effort and should not claim to prove safety.
Useful report fields could include:
- package name and version
- package location under
node_modules - direct or transitive dependency status
- dependency path / introduced-by chain
- approval status
- lifecycle script names and exact command values
- local files directly referenced by lifecycle commands
- obvious local files those scripts reference, where statically detectable
- file hashes for reviewed files
- risk signals found in referenced files
- change classification compared to a previously approved version, where possible
Useful risk signals could include:
- lifecycle script invokes a local JS file
- lifecycle script invokes a shell script
- lifecycle script invokes a package binary
- local file imports/requires another local file
- use of
child_process - use of
eval,Function, dynamic import, or obfuscation patterns - network calls such as
fetch,http,https,curl, orwget - access to
process.env - references to token/credential-like environment variables
- writes outside the package directory
- modification of
.npmrc,.gitconfig,.ssh, shell profiles, or CI-related files - remote code download
- base64 decode plus execute patterns
- implicit native build reason, such as
binding.gyp/node-gyp
Non-goals:
- Do not execute lifecycle scripts.
- Do not approve scripts automatically.
- Do not claim a package is safe.
- Do not replace human review.
- Do not attempt perfect JavaScript static analysis.
A best-effort local-reference walk and risk-signal report would still be a meaningful improvement.
The desired workflow would be:
- Dependency bot updates
package.json/ lockfile. - CI runs strict lifecycle script enforcement.
- CI detects pending lifecycle scripts.
- CI generates a review report as an artifact or PR comment.
- A human reviews the report.
- A human submits a separate approval or denial commit, if appropriate.
This turns the approval question from:
Do I approve this package name?
into:
Do I approve this package/version to run this install-time execution path?
That is a better security decision.
References
- GitHub Community discussion: Upcoming breaking changes for npm v12
https://github.com/orgs/community/discussions/198547 - npm approve-scripts documentation
https://docs.npmjs.com/cli/v11/commands/npm-approve-scripts/ - GitHub changelog: Upcoming breaking changes for npm v12
https://github.blog/changelog/2026-06-09-upcoming-breaking-changes-for-npm-v12/ - Microsoft Security Blog: Mini Shai-Hulud compromised npm packages and CI/CD credential theft
https://www.microsoft.com/en-us/security/blog/2026/05/20/mini-shai-hulud-compromised-antv-npm-packages-enable-ci-cd-credential-theft/
- Lingua principale
- JavaScript
- Stelle
- 780
- Fork
- 266
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/rfcs
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
[workshop-sync] workshop/side-quest-26-01-forecast-costs.md: forecast default history window is inaccurateForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadocumentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno