Repository navigation
fix(core): treat source, pipes, wrappers, TS runners and node . as executing scripts - #90
Conversation
A lifecycle hook that runs a package file through one of these forms was rated low instead of critical: - `.` and `source` are interpreters: their first operand is the script. - When any stage of a pipeline is an interpreter, the operands of the other stages (`cat setup | sh`) are treated as executed files. - A path-qualified wrapper counts by its basename (`/usr/bin/env node`). - `tsx` and `ts-node` are interpreters; `.mts` and `.cts` are code extensions, and an extension-less operand also tries `.ts`. - `node .` and `node <dir>` resolve the directory's `package.json` `main`, then `index.js`. Bump AUDIT_REVISION to 4: rule semantics changed, so audits persisted before this fix must be recomputed. Closes #86
- Cache the resolved entry file (or the miss) per directory for `node <dir>`, so many references to a directory with a huge `main` no longer rebuild and hash the candidate paths each time. - A relative path-qualified command word that names a package file (`./bin/env`, `bin/node`) is that file: it is scanned as a command and is not mistaken for the wrapper or interpreter it is named after. Absolute paths and unresolved relative paths still use the basename. - In a pipeline, only stages upstream of an interpreter stage have their operands followed, so `node build.js | tee report.md` does not scan the report. `sudo` is a wrapper, so `cat x | sudo sh` counts, `|&` is a pipe, and a newline right after `|` continues the pipeline. - A directory name with a dot (`node tools.v2`) resolves its entry file. Refs #86
…ll-scripts - A relative path-qualified command word that names a package file (`./bin/env`) is now both scanned as a file and still treated as the wrapper or interpreter it is named after, so `./bin/env node evil` scans `evil` as well as `bin/env`. The file is found by exact lookup, not the suffix trie. - A directory entry for a dotted name (`node tools.v2`) no longer hides a nested file the suffix lookup finds after a `cd`: both are followed. - A newline continues a pipeline only after a real pipe operator: an escaped `\|` is not one, and `|&` is. Refs #86
…uation - A relative path-qualified command word (`./node` after `cd bin`) is looked up with the path resolver, so the suffix lookup finds `bin/node`. The basename still plays the wrapper or interpreter role. - Punctuation is trimmed before the wrapper basename checks, so `(env node setup)` still reaches `setup`. Refs #86
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sentinel dependency audit — WARN · ✓ ok145 allow · 5 warn · 0 block · 0 error
▶ Run Sentinel · 150 packages audited · 2026-11-20T12:15:41.524Z · SBOM uploaded as a build artifact |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e0a3c5c4d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- A root `setup.js`, `setup.ts` or directory entry no longer hides a nested `scripts/setup` found by the suffix lookup after a `cd`: both are followed. - A bare wrapper or interpreter name (`sudo`, `env`, `tsx`, `node`, ...) may itself be a package file, so `package/<name>` is scanned when it exists, while the word keeps its wrapper or interpreter role. The suffix lookup stays limited to path-qualified words. Refs #86
Install hooks that ran a package file through a shell builtin, a pipe, a path-qualified wrapper, a TypeScript runner or Node's directory entry point rated low even when that file held a payload (#86). The
install-scriptsrule now treats all of these as executing the file:. ./setupandsource setup;cat setup | sh,cat setup |& sh,cat x | sudo sh(operands of stages upstream of an interpreter stage);/usr/bin/env node setup, and a package-local./bin/env node evil(the local file is scanned and keeps its wrapper role);tsx setup,ts-node setup(with.ts/.mts/.ctsresolution);node .andnode <dir>(viapackage.jsonmain, thenindex.js).The design follows #89: over-follow for detection, keep the work linear (the directory lookup is cached per directory), stay deterministic.
node build.js | tee report.mddoes not scan the report, becauseteesits downstream of the interpreter.AUDIT_REVISIONgoes to 4.Proof: 31 new tests in
packages/core/test/security-executors.test.ts, each failing before its fix (one is a timing bound).npm testpasses (1466 tests, 0 failures, 4 Linux-only skips). Reviewed with sol-loop: 4 rounds with gpt-6.2-sol. Sol verdict: approved.Closes #86.
Created with Claude Opus 5.5 in Claude Code (T3 Code). A Sonnet 5.5 subagent wrote most of the code.