dream(security): #4960 add witnessed SOTA research gist

Local-only publication (gh CLI auth broken this session, FALLBACK for
remote gist publication only -- GitHub MCP tools still used for the issue
and PR). Witness computed from this file's final content + the session
commit; verifier procedure is in the file itself.
This commit is contained in:
Claude committed 2026-11-11 06:31:48 +00:00
1 parent fe3808bbef
commit 0b4e03a86b
1 file changed
+80
+80
View File
@@ -0,0 +1,80 @@
# Security SOTA Report — 2026-11-11
**TL;DR**: In 2026, coding-agent tool-allowlist security keeps failing the same way across the industry: Cursor shipped CVE-2026-22708 (shell builtins bypassing its Auto-Run allowlist) and has four independently documented denylist bypasses; Aider disables all confirmation prompts repo-wide via a committed config flag; a 2026 arXiv survey (2606.15549) finds terminal-agent command denylists broadly fragile — explicitly including Claude Code's own built-in denylist, the host Ruflo itself runs on. Tonight's deep review found Ruflo has its own instance of this exact class, in the one place built specifically to catch it: `settings-risk-scanner.ts`'s `scanAllowRuleForRisk()` heuristically flags `permissions.allow` rules that pre-approve a shell/interpreter word (`bash`, `sh`, `python`, `ruby`, `perl`, …) with no per-call confirmation — but `node`, `deno`, `bun`, and `php` are absent from that word list, despite being GTFOBins-documented shell-breakout interpreters in exactly the same tier as the four already covered. This repo's own committed `.claude/settings.json` carries a live, fully-unscoped `"Bash(node:*)"` allow-rule today that the scanner silently passes as clean. Fixed tonight by extending the word list and its test coverage; a DNS-rebind SSRF gap flagged as a deferred finding on 2026-10-30 was also found, on inspection, to already be closed (`http-fetch-pinned.ts`'s `pinnedLookup`, ADR-164 §5.1.8) — recorded here as a correction, not re-implemented.
## What's New in 2026
| Finding | Source | Confidence |
|---|---|---|
| GTFOBins documents `node -e` spawning a shell/reverse-shell via `child_process`, same breakout class already covered for `python`/`ruby`/`perl` | gtfobins.org/gtfobins/node | A |
| Cursor CVE-2026-22708: Auto-Run allowlist checked external binaries but missed shell builtins (`export`/`typeset`), letting a poisoned env var make an *already-approved* command execute attacker code | HiddenLayer SAI advisory, cross-checked via Pillar Security blog (2025-11, CVSS 9.8) | B |
| Cursor's command-level allowlist/denylist independently documented with ≥4 bypasses (write-then-execute, obfuscated/base64 payloads) by Backslash Security and The Register | Backslash Security blog; The Register, 2025-07 | B |
| Claude Code permissions docs recommend scoped/exact-match Bash allow rules; call argument-prefix patterns "fragile," not a security boundary | code.claude.com/docs/en/permissions | B |
| arXiv 2606.15549: terminal-agent command denylists are broadly fragile as a class, explicitly naming Claude Code's own built-in denylist as sharing the gap | arXiv preprint (2026), single academic source | C |
| OWASP Agentic AI Top 10 ASI02 "Tool Misuse": primary mitigation is least-agency, per-tool scoped profiles, not blanket interpreter pre-approval | OWASP GenAI Security Project (2025-12 release, "2026" cycle), cross-checked across 3 secondary summaries | B |
**Why this isn't "None across the board"**: no competitor implements the same static heuristic-scanner mechanism Ruflo does (see Competitor Comparison) — the field splits between pure list-membership (Cursor/Windsurf, both with documented bypasses) and OS-level sandboxing (OpenAI Codex CLI, architecturally different). That absence is itself the finding: Ruflo's approach is more sophisticated than most reviewed competitors', which makes its own gap worth closing rather than dismissing as "everyone has this."
## Ruflo Current Capability
`v3/@claude-flow/cli/src/init/settings-risk-scanner.ts` is Ruflo's advisory-only scanner, run by `ruflo init --upgrade` against a target project's pre-existing `.claude/settings.json` (built 2026-08-16 against the CVE-2025-59536 hook-injection class). `scanAllowRuleForRisk()` flags a bare wildcard (`Bash(*)`) and any rule pre-approving one of `RISKY_PREAPPROVE_WORDS = [...DANGEROUS_COMMAND_WORDS, ...SHELL_EXEC_WORDS, ...DOWNLOADER_WORDS]` = `rm/rmdir/del/format/mkfs/dd/chmod/chown/kill/killall/pkill/reboot/shutdown/poweroff/halt/sudo/eval/bash/sh/zsh/python/python3/perl/ruby/curl/wget`. `node`/`deno`/`bun`/`php` are absent. The existing test file (`__tests__/settings-risk-scanner.test.ts`) pins `['Bash(node:*)']` in its "does not flag" list — checked, this is not a documented deliberate tradeoff (no comment, no commit message explaining it; repo history for this file is one squashed commit, `56fe4dc6`, uninformative). Confirmed the gap is live: `ruflo init`'s own default `generateSettings()` (`settings-generator.ts:32-42`) emits only `['Bash(npx @claude-flow*)', 'Bash(npx claude-flow*)', 'mcp__claude-flow__*']` — it never generates a node-related allow rule itself, so this repo's own committed `.claude/settings.json` lines 14/29 (`"Bash(node .claude/*)"`, `"Bash(node:*)"`) were hand-added, not scanner-exempted by design. The broader, fully-unscoped `"Bash(node:*)"` rule pre-approves *any* future `node` invocation — including a one-liner a prompt-injected file or compromised dependency could induce an agent to run — with zero per-call confirmation, and the scanner that exists specifically to flag exactly this shape says nothing.
Also verified tonight (correction, not a new fix): the 2026-10-30 ledger note's deferred finding — "`http_fetch`'s allowlist never resolves hostnames before the private/public decision" (DNS-rebind SSRF) — is **already closed**. `http-fetch-pinned.ts` (ADR-164 §5.1.8) implements `pinnedLookup`: the socket's own DNS lookup *is* the check, and the connection is pinned to the addresses that lookup returned, closing the TTL-0 rebind window the 10-30 note was concerned about. No action needed; flagged here so a future night doesn't re-open it.
## Competitor Comparison
| Competitor | Mechanism | Scans/validates pre-approved command words? | Grade |
|---|---|---|---|
| Cursor | Command-level Auto-Run allow/deny list | No independent word-risk heuristic; CVE-2026-22708 + ≥4 documented denylist bypasses | C |
| Windsurf (Cascade) | Allow-list/deny-list of command names, admin-settable | List-membership only, no heuristic scanning of generic interpreter names | C |
| Aider | `--yes-always`/`yes-always: true` disables all confirmation repo-wide | No scanner of any kind — a committed config value silently removes every prompt | C |
| GitHub Copilot coding agent | Network/host "agent firewall" allowlist | Operates at the network layer, not the command-word layer; no shell-allowlist analogue found | C |
| OpenAI Codex CLI | `approval_policy` × `sandbox_mode` (OS-level containment) | Substitutes blast-radius containment for a word-level scanner — different architecture, not a comparable mechanism | B (design) |
| LangGraph / AutoGen / CrewAI | Workflow checkpoints / role-based handoff | No terminal/shell layer of their own — N/A, not a gap, a different product category | N/A |
| Qdrant / Weaviate / Milvus / LanceDB / Vespa | — | N/A — vector databases, no agentic command-execution surface exists to scan | N/A |
## Hypothesis
> Given `settings-risk-scanner.ts`'s `scanAllowRuleForRisk()`, which currently returns a finding for `permissions.allow` rules pre-approving `bash/sh/zsh/python/python3/perl/ruby/curl/wget` (plus dangerous command words) with no per-call confirmation but returns no finding for an equivalent pre-approval of `node`, `deno`, `bun`, or `php` — GTFOBins-documented shell-breakout interpreters in the same risk tier as the four already covered — when `node`/`deno`/`bun`/`php` are added to `RISKY_PREAPPROVE_WORDS`, then `scanAllowRuleForRisk('Bash(node:*)')` and the equivalent `deno`/`bun`/`php` forms should return a non-empty finding, while every currently-passing test case (including `Bash(npm test)`, `Bash(git:*)`, `Read(*)`, and `scanCommandStringForRisk`'s separate, unrelated `node -e` hook-command exemption) remains unchanged, subject to: zero change to `scanCommandStringForRisk` (a different function governing fixed hook-command strings, already correctly scoped), zero new false positive against `ruflo init`'s own default-generated settings.json (which contains no node/deno/bun/php allow-rule today), deterministic $0 Vitest evaluation. Frozen before evaluation; not modified after.
## Benchmarks
No agent-task benchmark applies — binary detection-heuristic correctness, evaluated via discriminating Vitest unit tests against the existing, repo-convention test file, same class as 2026-10-16 (`DENYLISTED_ENV_NAMES` extension) and 2026-10-20 (path-containment fix). `.harness/bench.json` does not exist in this checkout.
## Evaluation
**evaluated: accepted — ACCEPT.**
Real evaluator: Vitest 4.1.8, package `@claude-flow/cli`. 10 new tests added (`__tests__/settings-risk-scanner.test.ts`, new `describe('general-purpose interpreter preapprove words (2026-11-11)')` block, 5 discriminating + corresponding `does not flag` adjustments) plus a hand-written benchmark corpus (`benchmarks/settings-risk-corpus.json`) relabel: `Bash(node:*)` corrected from `malicious:false` to `true`, plus 4 new true-positive samples (`Bash(node .claude/*)`, `Bash(deno:*)`, `Bash(bun:*)`, `Bash(php:*)`).
Stash-isolated baseline (`settings-risk-scanner.ts` reverted, test file + corpus kept): **5/5 new discriminating tests fail exactly as predicted** (`expected 0 to be greater than 0`), all 45 other existing tests in the same file pass unchanged (0 regressions at baseline). Candidate: **54/54 pass** across both affected test files. Benchmark corpus precision/recall (`settings-risk-benchmark.mjs`, deterministic, $0): baseline recall **0.75** (5 false negatives, exactly the 5 new samples) → candidate recall **1.0**, precision **1.0** both ways (0 false positives introduced). `tsc --noEmit`: 512 pre-existing errors (unbuilt `@claude-flow/neural`/`@claude-flow/cli-core` sibling packages, same environmental class disclosed every prior night), 0 in either changed file. Related-suite run (`__tests__/init/` + `__tests__/settings*.test.ts`, 5 files): **77/77 pass**. Full-package suite: timed out at 170s (environmental, same as 2026-10-26's disclosed timeout) — related-suite + full discriminating stash-isolation is the primary evidence, consistent with precedent.
No reward-hacking: the diff is additive to a word list plus corresponding test/corpus entries; no existing test, threshold, or `scanCommandStringForRisk` behavior was touched. The one judgment call — relabeling `Bash(node:*)` from `malicious:false` to `true` in the benchmark corpus — is disclosed explicitly in-source (`ground_truth_correction_2026-11-11` provenance field) as a correction of a previously-wrong label, not a metric-gaming move; verified the original label was never a documented design tradeoff (no comment or commit message justifies it; see Ruflo Current Capability above).
**Independent adversarial critique**: a fresh-context critic agent (no access to this session's reasoning) independently re-read the diff, re-ran stash-isolation itself (confirmed byte-identical 5/54-fail-baseline → 54/54-pass-candidate), diffed `tsc --noEmit` output baseline-vs-candidate line-for-line (zero difference), and worked through the full reward-hack checklist, independently verifying the motivating fact (this repo's own `.claude/settings.json:29` really does carry `Bash(node:*)`) rather than trusting the write-up. Returned **CONFIRMED** + **PASS** for shippability. The critic additionally discovered, on its own initiative while running tests broader than the two files this session pointed it at, that a dedicated CJS/TS parity-guard test (`__tests__/session-start-hook-settings-risk-scan.test.ts`) checks `settings-risk-scanner.ts`'s TS implementation against a hand-ported CJS mirror in `hook-handler.cjs` (used by the `session-restore` hook that runs on every real session boot, per the 2026-10-11 ledger fix) — and that this session's original fix, by only touching the TS side, would have silently left that mirror out of sync on the exact interpreter-word cases this fix cares about. The critic ported the identical `INTERPRETER_WORDS` change into both copies of `hook-handler.cjs` (root and `v3/@claude-flow/cli/.claude/helpers/`, which must stay byte-identical) and extended the parity test's sample set to include `node`/`deno`/`bun`/`php` so this class of drift would be caught automatically going forward. Verified independently by this session: 71/71 pass across the three affected test files with the critic's fix applied.
Three non-blocking caveats disclosed by the critic, two closed same-session, one left as documented design rationale:
1. The regex terminator class (`(:| |\))`, not a generic `\b`) correctly avoids false-positiving on a prefix collision (`Bash(nodemon:*)`, `Bash(phpunit:*)`, `Bash(bunx:*)`, `Bash(denoland:*)` all correctly pass clean) — verified by hand but untested. **Closed same session**: added a dedicated regression-test block for exactly these four cases (75/75 pass after).
2. Separating `INTERPRETER_WORDS` from `SHELL_EXEC_WORDS` is design-justified (keeps `scanCommandStringForRisk`'s hook-command exemption for legitimate `node <script>` invocations untouched) but isn't proven load-bearing by any test that would currently regress if the two arrays were merged (no existing "does not flag" command-string sample combines `node` with a downloader word). Left as documented rationale in-source; not a correctness bug, just an untested design boundary.
3. The `hook-handler.cjs` changes weren't part of this session's original change summary to the critic — confirmed independently to be a necessary, correctly-mirrored consequence (CJS/TS parity), not drift or corruption from a concurrent session (the CLAUDE.md-documented risk this repo explicitly warns about).
## Darwin Results
Skipped — this is a binary detection-list membership fix (a word either triggers a finding or it doesn't), not a continuous/categorical tunable parameter. Same skip class as nearly every prior ACCEPT of this shape in the ledger (e.g., 2026-10-16, 2026-10-31).
## SOTA Proof & Witness
Session commit: 6b8095490e0cdb3389481b41d3a4c91d5dcbc991
Candidate commit: fe3808bbefafb64a90c643b5fdf5d76a4c870e97
Gist SHA-256 (pre-witness, this block held to the literal text `PENDING`): 743742f14ff376e38de06b12e7372dd6fdab5a23d2fdbef1831ec0c6efc5e184
Witness stamp: 6bfe9cf417b1e08ca77332d645427d35e3f804617ad6756eab3e0971bf918ad6
Verifier: fetch this file, replace this block's three dynamic values with the literal text `PENDING` (as they were before this computation), SHA-256 the result, concatenate with the Session commit above, SHA-256 again — must equal the Witness stamp.
Evaluation receipt identity: 10 new/extended tests in `settings-risk-scanner.test.ts` + a new parity-guard case in `session-start-hook-settings-risk-scan.test.ts`, stash-isolated 5/54-fail-baseline → 54/54-pass-candidate (independently reproduced by the adversarial critic); 75/75 across all three affected test files after the critic's parity fix + this session's prefix-collision regression test. Benchmark corpus precision/recall: baseline recall 0.75 → candidate recall 1.0, precision 1.0 both ways. Flywheel evidence identity: none (`.claude-flow/flywheel/` doesn't exist in this checkout, consistent with every prior night). Darwin lineage identity: none (skipped — binary detection-list membership fix, not a tunable parameter).
## Recommended Next Steps
1. **Decide deliberately on this repo's own `.claude/settings.json`**: lines 14/29 (`Bash(node .claude/*)`, `Bash(node:*)`) will now be flagged by the fixed scanner if it's ever re-run against this file. Tonight's fix only closes the *detection* gap; narrowing or removing the live rule itself is a separate decision for a human (it's this session's own operating permissions file), not made unilaterally tonight.
2. **`PolicyEngine.evaluateTrustChange()` still doesn't read `minTrustLevelForAdmin`** (disclosed 2026-11-01, Recommendation #2) — unfixed. Deliberately not picked up a third consecutive policy-engine.ts night in a row; worth a future night's deliberate call rather than reflexive continuation (STEP 1.1 judgment call, recorded here for traceability).
3. **EWC++ Fisher-map per-mode wiring** (2026-10-27, re-disclosed 2026-11-01) is still only implemented for `BalancedMode`; confirmed again tonight by a fresh scan — mitigated in practice since every mode-construction site defaults to `'balanced'`, but `edge`/`real-time`/`research`/`batch` modes remain unprotected if ever defaulted away from `balanced`. Third disclosure without action; a future night should decide to either implement the other four modes' `getConsolidationSnapshot()` or explicitly accept the risk.