Repository navigation
Gate npx and npm exec on vuln verdicts before the package runs - #229
juangaitanv wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
Automated review risk: 4/5.
The new npx/npm exec gate can allow a different package than the one it verdicted, and npx_as_npm_exec panics on common incomplete flags. Existing install wrappers are only signature-plumbed and look unchanged.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
… registry and npm config files into the check
|
Review 6168358861 (risk 4/5) addressed at b4aaf6c: the panic and the dropped scope-registry/config flags are fixed, with tests that fail on the old head. The installed-bin finding is declined as out of scope; the brief excludes re-gating locally installed packages, and the docs now say so. The shim docs name |
There was a problem hiding this comment.
Automated review risk: 4/5.
The npx/npm exec gate is real for the common forms the new tests cover, but a non-boolean --flag=pkg spelling still skips it and runs the package. The earlier panic, registry-flag, and shim-doc comments are fixed in this diff; the installed-copy note is an accepted, documented limit.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
|
Review 6169043446 (risk 4/5) addressed at a370c8b. The |
There was a problem hiding this comment.
Automated review risk: 4/5.
The new npx/npm exec gate blocks the tested fetch path, including a vulnerable transitive, but it verdicts a fresh global resolution of the spec and then executes npx. A local binary that satisfies the spec is therefore not what was checked, and --userconfig/--globalconfig deliberately drops the tree pass while still running under the default fail-open policy.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
|
Review 6169940229 at dc6c8e6: the registry-key nitpick is fixed. The two high findings repeat documented scope decisions and are declined in their threads. Installed bins are not re-checked, per the brief. With --userconfig/--globalconfig only the named packages are checked, which is the gate's existing named-only policy: blocks when logged in or fail-closed, warns in public mode. |
There was a problem hiding this comment.
Automated review risk: 4/5.
Ordinary npx <pkg> gating is covered and tested, but several accepted flags vet a different install than the one npx runs, so a clean verdict can still execute an attacker-chosen tree. Fail-closed does not stop those argv shapes.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
…nd npm exec They change which npmrc, registry or cache npm installs from, and the check cannot follow them.
|
Review 6177098968: the high finding (--prefix/--cache/--offline vet a different install than npx runs) is fixed in f66cd73; those flags now make the argv unverifiable. Details: #229 (comment) |
There was a problem hiding this comment.
Automated review risk: 4/5.
Basic npx pkg and npm exec --package=<pkg> gating, including transitive advisories, is in place, but the npx grammar vouches for a different install than npm runs. Post-command npm options are ignored, and --userconfig/--globalconfig skip the tree pass while npx still applies them.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
…exec A config file can set the registry, cache or offline mode, and the check does not read it.
|
Review 6177540675: config flags (r4790718257) fixed in fe61ef9, now unverifiable; flags after the npx command (r4790717995) declined with a real-npx probe, details in the thread. |
There was a problem hiding this comment.
Automated review risk: 4/5.
The main npx/npm exec path blocks a vulnerable transitive before exec, and the declined post-command npx flags plus the userconfig/globalconfig fix were not reopened. A passing verdict can still describe a different binary or tree than the one that runs, and some unambiguous npm spellings skip the check unless fail-closed is set.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
They change the dependency tree npm installs, and the tree pass does not carry them.
|
Review 6178120176: --force/--legacy-peer-deps (r4791166973) fixed in 97d48c7, now unverifiable. Installed local bin (r4791166795) is a stated Known limit; unverifiable-runs-in-public-mode (r4791167144) is the chosen policy, with blocking in every mode listed as an option; Debug quoting (r4791167299) kept so empty and padded tokens stay visible. Details in each thread. |
There was a problem hiding this comment.
Automated review risk: 4/5.
Plain npx pkg and npm exec pkg are gated, but the new grammar rejects many argv shapes npm 10.9.9 still resolves to a single fetch, and that path runs the real binary unless fail-closed is on. Default corgea npx / npm exec can be bypassed with one unambiguous flag or shorthand.
Critical or high-priority changes must be addressed.
Automatic approval was not submitted: automated review found critical or high-priority findings.
|
Review 6178798028: the one finding (r4791685612) is blocked when the gate fails closed; it concerns public-mode policy and spellings the grammar could also accept. Parked as a follow-up; details in the thread. |
Why
npx foodownloads a registry package and runs it straight away, and nothing checked it.execwas not an install subcommand, socorgea npm execpassed it through unchecked, andcorgea npxdid not exist.What changes
corgea npx <pkg>andcorgea npm exec|x <pkg>work out which packages npm would fetch and check them against Corgea verdicts before anything downloads. That means the--package/-pspecs, or the command spec when no--packageis given. The check is the same asnpm install -g <spec>and covers transitive dependencies. A flagged package blocks with the same reportnpm installprints. A clean one runs the realnpx(ornpm exec) with argv untouched and returns its exit code.--tag,--before,--registryand--@scope:registry=are passed into the check, so it covers the version npm would actually fetch.?) and block when the gate fails closed.corgea shims installnow also shims plainnpx.Invariants
--package-lock-only --ignore-scriptstree pass.--, common switches such as-y,--package/npx's-p,-c/--call, and registry, tag and log flags with a value that is not empty, dash-led or space-padded; a package spec or the command name holds no whitespace (a-cvalue may). Any other argv is unverifiable: nothing in it is checked or shown as ✓, it blocks when the gate fails closed, and otherwise it runs with a warning and the hintnpx --package=<pkg> -- <cmd>.What can go wrong
npm exec eslint --fixis unverifiable;npx eslint --fixis accepted. npx's--shell,-c=x,-p=xand--no-yesare unverifiable too.-grule. In fail-open public mode their dependencies run unchecked, with a warning.Known limits
--prefix/-C,--cache,--offline,--prefer-offline,--userconfig,--globalconfig,--forceand--legacy-peer-depsare unverifiable (corgea npx --prefix dir pkg): they change which npmrc, registry, cache or dependency tree npm installs, and the check cannot follow them. They block when the gate fails closed and warn otherwise.corgea npx eslintwithnode_modules/.bin/eslintpresent), and the gate checks the registry resolution of the spec, not that installed copy..npmrcthat setspackage=is not read (package=evilin.npmrc, thencorgea npx tool): npx fetches that package unchecked.corgea npm --yes true exec <pkg>andcorgea npm --package x exec <pkg>route on the wrong token and run unchecked, even fail-closed.installhas the same hole. It gets its own PR.Compatibility
corgea npx.corgea npm execused to be a silent passthrough and is now gated.npm install -gwith--tag=/--before=now keeps its tree pass. It used to fall back to checking named packages only.--call/-cwith no--packagefetches nothing and still runs unchecked.How to validate
Real npm 10.9.9 and 11.21.3, a fresh npm cache, spy wrappers on
npm/npx, andCORGEA_INSTALL_GATE_FAIL_CLOSED=1:corgea npx lodash@4.17.20exits 1 and lists CVE-2021-23337 and others.~/.npm/_npxstays empty and npx is never spawned.corgea npx --yes cowsay@1.6.0 --no-such-flag-xyz -f nonexistent-cowchecks 33 packages, then prints exactly what plain npx prints.Fuzz:
bash .cos/fuzz/run-all.sh "$PWD"(local harness, not committed: about 1 MB of corpora).Review first:
src/precheck/parse.rsparse_exec_args: every accepted argv must name exactly what npm fetches; everything else returnsErr.src/precheck/mod.rsrun_npm_exec: anErrtakes the existing unverifiable path, with no ✓.src/precheck/tree.rs: the global-install allowlist now includes--tag=and--before=.