Skip to content

Detection gap: install-scripts does not follow npm/yarn/pnpm run into package scripts #85

Closed

Description

@tonibergholm-codento

Kind

Missed detection (should have been flagged, wasn't)

Package name and version

Synthetic pattern, no real package. Found during the security audit hardening (#84); listed as a follow-up in ADR-0056.

Expected vs actual verdict

A lifecycle hook that calls a script through the package manager is not followed into that script:

{ "scripts": { "postinstall": "npm run setup", "setup": "node setup.js" } }

If setup.js downloads and runs a payload, the install-scripts rule rates the hook low. The same payload behind "postinstall": "node setup.js" is critical. The base branch had the same miss; it is not a regression.

The setup.js file is still scanned by the other rules (secret-exfil, network-egress, obfuscation), so the payload itself is seen. What is lost is the escalation that comes from the code running at install time.

The pattern

A lifecycle hook runs npm run <name>, npm run-script <name>, yarn run <name>, yarn <name> or pnpm run <name>, and scripts[<name>] runs the payload.

Suggested approach

In packages/core/src/rules/install-scripts.ts, when a simple command is npm|pnpm run|run-script <name> or yarn [run] <name>, look up scripts[<name>] in the same package.json and parse it as a command line.

  • Bound the recursion depth.
  • Remember visited names, so a script that calls itself terminates.
  • Ignore names that are not defined in scripts.

Add a synthetic test: the payload behind npm run setup must be critical, and npm run build with a benign build script must stay clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageNew issue awaiting triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions