Skip to content

Detection gap: install-scripts misses source, pipes, pathed wrappers, TS runners and node . #86

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

The install-scripts rule recognises a fixed set of interpreters (sh, bash, node, python, and so on), the command word itself, and every operand with a code extension. These forms still execute a package file, but the hook is rated low instead of critical when that file holds a payload:

Lifecycle command What runs
. ./setup or source setup setup, sourced into the shell
cat setup | sh setup, piped into a shell
/usr/bin/env node setup setup (a pathed wrapper is not recognised as env)
tsx setup or ts-node setup setup.ts
node . the file named by main in package.json

The file is still scanned by the other rules, so the payload itself is seen. What is lost is the install-time escalation. Some of these forms were also missed on the base branch.

The pattern

A lifecycle hook runs a package file through a shell builtin, a pipe into an interpreter, a path-qualified wrapper, a TypeScript runner, or Node's directory entry point.

Suggested approach

In packages/core/src/rules/install-scripts.ts:

  • Treat . and source as interpreters, so their first operand is the script.
  • When a simple command pipes into an interpreter (cat x | sh, cat x | node), treat the files read by the earlier commands as executed.
  • Take the basename of a path-qualified command word before checking it against the wrapper and interpreter lists (/usr/bin/env becomes env).
  • Add tsx, ts-node and bun to the interpreters, resolving .ts and .mts as well.
  • For node . or node <dir>, resolve that directory's package.json main, then index.js.

Add a synthetic test for each row. Each must be critical with a payload, and stay clean with a benign file.

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