Repository navigation
Closed
Description
Why
A recent merge (#99) shipped a CRITICAL security regression — the meta-flag passthrough path bypassed per-tool environment hardening (issues #36/#37/#38), silently re-exposing env-injection RCE vectors for 7 infrastructure binaries (docker, kubectl, aws, psql, gh, glab, gt). It was caught by Codex review before reaching production, but it shows the hardening surface is fragile and not comprehensively verified.
This issue tracks a full-codebase, line-by-line audit of contextcrawler via Codex peer review — every line checked against the application's security model, branding, and stated goals.
Audit criteria — every line is checked against
- Security model
- Environment-injection hardening: every spawned subprocess must strip the dangerous env vars for its tool class (
RUBYOPT,PYTHONPATH,NODE_OPTIONS,RUSTC_WRAPPER,GIT_*,DOCKER_CONFIG,KUBECONFIG,AWS_*,RIPGREP_CONFIG_PATH, ...). See SECURITY [P1]:RIPGREP_CONFIG_PATHenv var + rg--preenables silent arbitrary-code-execution via everycontextcrawler grepcall #32, harden(git): strip env-driven config-injection vectors + reject -c <override> in git wrapper #35, harden(python/ruby/jvm/dotnet): strip PYTHONPATH/RUBYOPT/JAVA_TOOL_OPTIONS/DOTNET_STARTUP_HOOKS #36, harden(node): strip NODE_OPTIONS + NPM_CONFIG_* for npm/pnpm/npx + JS toolchain #37, harden(cloud): strip KUBECONFIG / DOCKER_CONFIG / AWS_CONFIG_FILE for k8s/docker/aws/psql wrappers #38. - Forbidden-argument rejection:
--pre/--pre-glob/-z(rg), config-injection flags (git), etc. - Trust gate, integrity (SHA-256 hook verification), supply-chain gate.
- Known open vuln: prompt-injection affecting agent integrations — verify status and surface area.
- No command-injection / path-traversal / TOCTOU in the proxy path.
- Environment-injection hardening: every spawned subprocess must strip the dangerous env vars for its tool class (
- Correctness
- Filters must never corrupt output (the curl float-precision class — feat(curl): losslessly minify JSON response bodies #94).
- Filters must never bloat (filters: universal no-bloat guard — never emit output larger than raw #95) — guard present and universal.
- Filtered JSON / structured output must stay valid for downstream consumers (
| jq). - Fallback path must never silently lose the user's command.
- Branding & goals
contextcrawlernotrtkin user-facing strings, help text, hook scripts (branding_lint covers some — verify coverage).- Behaviour matches the stated goal: a transparent, lossless-by-default token-optimisation proxy.
- Code quality
- No
unwrap()/panic!on the proxy hot path that could kill a user's command. - Exit-code propagation correct.
- Test coverage on every security-relevant path.
- No
Scope — ~78k LOC, 8 review groups
| # | Group | Files | ~LOC | Priority |
|---|---|---|---|---|
| G1 | Security core | core/utils.rs, hooks/trust.rs, hooks/integrity.rs, hooks/permissions.rs, hooks/supply_chain_gate.rs, hooks/tirith_gate.rs |
~8.3k | CRITICAL |
| G2 | Hook system + dispatch | hooks/init.rs, hooks/hook_cmd.rs, hooks/hook_check.rs, hooks/rewrite_cmd.rs, hooks/hook_audit_cmd.rs, main.rs |
~12.2k | CRITICAL |
| G3 | Filter engine + tracking | core/toml_filter.rs, core/filter.rs, core/tracking.rs, core/config.rs, core/stream.rs, core/tee.rs, core/runner.rs, core/telemetry*.rs, core/display_helpers.rs |
~8.7k | HIGH |
| G4 | Command filters: git + cloud | cmds/git/, cmds/cloud/ |
~12.5k | CRITICAL (RCE-adjacent) |
| G5 | Command filters: system + rust + js | cmds/system/, cmds/rust/, cmds/js/ |
~12.2k | HIGH |
| G6 | Command filters: python + ruby + go + jvm + dotnet | cmds/python/, cmds/ruby/, cmds/go/, cmds/jvm/, cmds/dotnet/ |
~11.7k | HIGH |
| G7 | Discover + analytics + learn + parser | discover/, analytics/, learn/, parser/ |
~13.2k | MEDIUM |
| G8 | TOML filter configs + test harness | src/filters/*.toml (60), tests/*.rs |
— | MEDIUM |
Method
- One Codex pass per group (large groups split into sub-passes for context budget).
- Each pass is adversarial: assume the code is wrong, prove it right.
- Findings triaged CRITICAL / IMPORTANT / NICE-TO-HAVE.
- CRITICAL/IMPORTANT findings → fixed on dedicated branches, each Codex-re-reviewed before merge.
- Progress tracked as a checklist on this issue; per-group finding summaries posted as comments.
Progress
- G1 — Security core
- G2 — Hook system + dispatch
- G3 — Filter engine + tracking
- G4 — Command filters: git + cloud
- G5 — Command filters: system + rust + js
- G6 — Command filters: python + ruby + go + jvm + dotnet
- G7 — Discover + analytics + learn + parser
- G8 — TOML filter configs + test harness
Metadata
Metadata
Assignees
Labels
No labels
Activity
thehoff commentedon May 20, 2026
G1 — Security core — findings (3 Codex passes, all verified against source)
CRITICAL
hooks/integrity.rs:286,308— runtime integrity check fails OPEN onNoBaseline.runtime_check()treats a missing.rtk-hook.sha256baseline as "silent, continue". Deleting the baseline file makes a tampered hook execute undetected. Verified: the(true, false)arm →NoBaseline→runtime_checkcontinues.Fix: fail closed on
NoBaseline— block and require reinstall/re-baseline.Defence-in-depth gates bypassed on the live hook path.
tirith_gate::checkandsupply_chain_gate::checkare invoked only fromrewrite_cmd.rs(thecontextcrawler rewritesubcommand). The installed PreToolUse hook callscontextcrawler hook claude→hook_cmd.rs::process_claude_payload, which runs permissions + rewrite but never invokes either gate. Verified: zerotirith/supply_chainreferences inhook_cmd.rs.Fix / decision needed: wire both gates into
process_claude_payload, or converge the two entrypoints. (Design call — see note below.)core/utils.rs:346-383— PATH resolution trusts inheritedPATH.resolve_binaryhas no trusted-path notion; an attacker-controlled earlierPATHentry wins, and the fallback is bare-name exec. This is already tracked as open issue harden(PATH): trusted-PATH resolution for wrapped binaries (defer trojan-on-PATH defense) #40 — the audit re-confirms it.IMPORTANT
core/utils.rs:626-679—secure_git_commandmisses--config-env(documented git env-injection RCE), and the forbidden config-key set omitsalias.*,credential.helper,filter.*(all exec-capable).core/utils.rs:1088-1137—secure_cargo_commandstripsRUSTFLAGSbut notCARGO_ENCODED_RUSTFLAGS(higher precedence).core/utils.rs:2162-2209—secure_node_commandstripsNODE_OPTIONSbut notNODE_PATH(module-shadowing vector for npm/pnpm/vitest/eslint/prettier/prisma/next).hooks/integrity.rs:74-99— the expected hash is a writable same-directory sidecar; an attacker who can write the hook dir replaces both hook and baseline and stays green.hooks/supply_chain_gate.rs— fails OPEN: any TOML-parse / registry-timeout / OSV-lookup error becomesUnavailable, and the caller only blocks onBlock.hooks/supply_chain_gate.rs:229-262— detection is raw-substring matching;/usr/bin/npm install,bash -lc 'npm install x',$(npm install x)all bypass it.NICE-TO-HAVE
hooks/integrity.rs:258-327— recovery text still emitsrtk init/rtk verify/rtk-rewrite.sh.Confirmed airtight (positive results)
apply_universal_env_strip— coversLD_PRELOAD,DYLD_INSERT_LIBRARIES,LD_AUDIT,BASH_ENV,PROMPT_COMMAND,IFS,BASH_FUNC_*sweeps.secure_*_commandbuilders airtight (rg, python, ruby, jvm, dotnet, go, kubectl, docker, aws, psql, curl, wget, gh, glab, gt, meta).check_forbidden_rg_args—--pre/--pre-glob/-z/--search-zipblocked, no=value/bundling bypass.scrub_secrets— Bearer /--password=/ URL creds / API keys caught, no bypass shape found.trust.rs— fail-CLOSED; corrupt/unreadable trust state →Untrusted.permissions.rs— fail-CLOSED; parse error →Default→ask, notallow.unwrap()/panic!on attacker input inutils.rs; no TOCTOU; no user-facingrtkstrings inutils.rs.Note on finding 2: the docs describe Tirith as "opt-in", so partial intent is plausible — but a defence gate that only fires on a non-default subcommand is a real gap. Needs an explicit design decision, not a silent fix.
thehoff commentedon May 20, 2026
G2 — Hook system + dispatch — findings (4 Codex passes)
CRITICAL
hooks/hook_cmd.rs— hook payload parsing fails OPEN. Malformed JSON, missing/wrong-type fields, or oversized stdin never emit a blocking verdict — malformed JSON logs to stderr and returnsOk(()), shape errors becomeIgnore, oversize stdin returnsErrwith no JSON. Net: any of these → the agent's command runs unchecked. Lines 16-25, 43-55, 300-307, 365-385, 424-440.Fix: fail closed — emit a
denyJSON on any payload error.main.rs:3483— proxy mode argument injection via lossyOsString+ auto-split.contextcrawler proxylossily converts the first arg to UTF-8 then runs it throughshell_split. A binary path containing whitespace (/Applications/My Tool/bin/x) is split into wrong tokens → wrong binary/args spawned silently.Fix: keep argv as
OsStringthrough toCommand; make shell-splitting opt-in, not a heuristic.IMPORTANT
hook_cmd.rs— deny output contract is inconsistent across runtimes; native-hook deny emits nothing (relies on the harness treating empty output as deny — undocumented/untested). Stalertkin emitted strings (hook_cmd.rs:53,172).hook_cmd.rs— rewrite semantic safety:&&/heredoc/already-prefixed verified safe;;,|, backtick/$(...)unverified — needs separator-specific tests.hook_cmd.rs:345,rewrite_cmd.rs:84— non-test.unwrap()onas_object_mut()and anunreachable!()on the payload path.main.rs:2560— absolute-path bin (/usr/bin/npm) doesn't matchMETA_PASSTHROUGH_BINS→ skipssecure_meta_commandenv hardening, falls torun_fallback. Same vuln class as the fix: complete pre-clap intercepts — meta flags + grep flag fallbacks #99 CRITICAL. Fix: basename-normalise before the membership check.main.rs:1737— grep-lshort flag collides with internal--max-len; shadows standardgrep -l <file>.init.rs:3744—patch_gemini_settings()silently replaces a malformedsettings.jsonwith{}— destroys user config on parse failure.init.rs:2762,2779,2825—RTK_CLAUDE_DIR/CODEX_HOME/HERMES_HOMEenv vars accepted verbatim as write/delete roots; a poisoned.envredirects writes outside~/.claude.init.rs:549,1395,3298— uninstall matches the hook entry by substring on the command string; an unrelated hook mentioning the filename gets deleted too.hook_check.rs:38-86—status()reports healthy on a stale registration without verifying the target binary exists/is executable → silent-broken-hook false negative.hook_audit_cmd.rs:9-15,74-83— log path resolved fromRTK_AUDIT_DIR/HOME,read_to_stringwith no canonicalisation/symlink-check/size-cap → symlink-to-device or multi-GB log hangs/OOMs.NICE-TO-HAVE
init.rs:3439— install-detection grepsCLAUDE.mdfor substringrtk; stale + false-positive-prone. Use the exact block marker.hook_check.rs:127,186,198— on-disk marker still# rtk-hook-version:.Confirmed clean
main.rs:run_fallbackintegrity, exit-code propagation,check_forbiddenordering, integrity gate wiring — all clean.init.rs: written hook-script content (no stalertk, paths properly constructed), integrity-baseline write, panics, TOCTOU — clean.hook_cmd.rs:&&preservation, heredoc skip, no-double-wrap — verified safe.G1 finding re-confirmed: zero
tirith_gate/supply_chain_gatecalls inhook_cmd.rs.G2 — Hook system + dispatch
thehoff commentedon May 20, 2026
G3 — Filter engine + tracking — findings (3 Codex passes)
IMPORTANT
core/toml_filter.rs:492—match_outputshort-circuit evaluates AFTER thereplacestage. Areplacerule that strips error markers (FAILED,error:) means theunlessguard sees scrubbed text → a real build failure silently short-circuits to the filter's fixed "ok" message. Fix: snapshot raw output beforereplace; evaluateunless/match_outputguards against the snapshot.core/filter.rs:327,core/toml_filter.rs:541— unchecked arithmetic on config-reachable line caps:smart_truncateunderflows on--max-lines 0;head_lines + tail_linescan overflow before the slice. Fix:saturating_*, rejectmax_lines = 0at parse time.core/tracking.rs:1355—RTK_DB_PATH/config.tracking.database_pathopened verbatim — no canonicalisation (symlink/device redirect) and no0600on create, so the user's command-history DB is world-readable at default umask. Fix: canonicalise +$HOME-confine +0600.core/stream.rs:342,391,493—run_streaminguses an unboundedmpsc::channel()and grows raw/filtered buffers with no end-to-end cap → OOM on a huge-output command. (exec_capture_with_limitsIS capped — only the streaming path is exposed.) Fix: bounded channel + output cap on the streaming path.core/stream.rs:345,422—BufReader::lines().map_while(Result::ok)is strict UTF-8 — silently truncates child output at the first non-UTF-8 byte. Fix: byte-line read + lossy conversion.core/tee.rs:37,107—RTK_TEE_DIR/config controls the tee path; raw child output written verbatim viafs::write— no0600, no symlink-safe open, no size cap. Fix: confine dir,OpenOptionswith restricted perms, size cap.core/display_helpers.rs:203—week_start[5..]/week_end[5..]sliced without length check → panic on malformed date data. Fix:.get(5..)with fallback.TELEMETRY — flagged for a product decision (not a code bug)
telemetry.rs/main.rs:2493—maybe_ping()phones home. It IS gated (compile-timeRTK_TELEMETRY_URLmust be set,RTK_TELEMETRY_DISABLED=1opts out, consent required) and the opt-out works. Payload:device_hash, version/OS/arch/install-method, first-word-only command aggregates (NOT full argv), savings stats, hook type, config counts. No raw argv, paths, or secrets transmitted. Two notes: (a) the endpoint URL is compile-time-injected, invisible in source; (b) payload/user-agent stillRTK-branded. Given the local-first / cloud-independence posture — recommend an explicit decision: keep gated, default-off, or strip telemetry from the fork entirely. Your call.NICE-TO-HAVE
core/tracking.rs:570— row prune has noVACUUM; disk not reclaimed. AddVACUUMorPRAGMA auto_vacuum.core/tracking.rs:382— WAL/busy-timeout PRAGMA errors silently ignored; no reopen path for a locked/corrupt DB.telemetry_cmd.rs:57— user-facing copy still saysRTK/rtk.Confirmed clean / SAFE
SQL injection — SAFE: all
tracking.rsinserts/queries use bound?params; noformat!-built SQL.Secret scrubbing — SAFE:
original_cmd/rtk_cmd(and parse-failure rows) go throughscrub_secretsbeforeINSERT.ReDoS — SAFE: filter engine uses Rust
regex/RegexSet(linear-time, no backtracking).Filter code-execution — SAFE: the TOML filter pipeline is pure data transformation; no
Command/eval/shell-out.Trust gating — SAFE: project/user filter files gated before load; can't shadow built-ins.
Subprocess deadlock — SAFE: stdout/stderr drained concurrently; no pipe-buffer deadlock.
Tracking panics — SAFE: tracking errors swallowed;
track*never panics the parent.RTK_DB_PATH/~/.config/rtk//RTK_DATA_DIRpaths — intentional legacy compat identifiers, not stale branding.G3 — Filter engine + tracking
thehoff commentedon May 20, 2026
G4 — git + cloud command filters — findings (3 Codex passes)
CRITICAL
cmds/cloud/curl_cmd.rs:24-35— curl-K/--configdeny-list bypassed by attached-value form. The forbidden-arg check matches-K/--configas standalone tokens but NOT-K=file/--config=file, which curl accepts.curl -K=evil.curlrc→ arbitrary curl-flag injection from a file, gate never fires. Fix: normalise each arg (strip leading-, split on=, take the key) before the deny check; regression-test-K=file.cmds/cloud/wget_cmd.rs:10-31,62-78— wget gate misses dangerous flags entirely.--output-document/-O(arbitrary file overwrite),--input-file/-i(arbitrary file read as URL list),--load-cookies(cookie-theft pivot) are not in the deny-list, in any form. Fix: add all three (+ attached-value normalisation per finding 1); test each bypass shape.IMPORTANT
cmds/cloud/psql_cmd.rs:39-40— verbose mode logs the raw psql argv, which can hold a DSN with an inline password (postgres://user:pass@host). Fix: run the argv throughscrub_secretsbefore logging.cmds/git/diff_cmd.rsnormalize_diff_args— the--re-insertion assumes the first--is the path separator; an arg starting with--or unexpected ordering can mis-place it, promoting a path to a revision. Fix: defensive ordering validation.cmds/git/git.rs—run_status(compact mode),run_stash(list/show),run_worktree(list) apply the output filter BEFORE checking git's exit code → a non-zero git exit is absorbed, caller sees apparent success with empty/truncated output. Fix: propagate the exit code on all three before/around filtering.cmds/git/gt_cmd.rs:139-141—run_otherdoesto_string_lossy()onOsStringargs before forwarding unknowngtsubcommands to git; non-UTF-8 branch names/paths get silently mangled. Fix: keepOsString/OsStrthrough the dispatch.NICE-TO-HAVE
cmds/git/git.rs:523— stalertkin a user-facing string.cmds/cloud/container.rs:204,374— twortkhelp/usage banner strings.Confirmed clean / PASS
git command construction — SECURE: every spawn in
git.rs/diff_cmd.rsroutes through the hardenedgit_cmd/secure_git_commandbuilder; no bareCommand::new("git"). Exec-capable-cconfig keys (core.sshCommand,core.fsmonitor, …) rejected upstream inmain.rs.gh/glab/gt — SECURE: all three use hardened builders; no bare spawns.
--json/--jq/--templatepassthrough — PASS: gh/glab treat them as value-flags, return raw stdout on parse failure — structured output not mangled.cloud hardened builders — PASS: aws/docker/kubectl/curl/psql/wget all spawn via their
secure_*_commandbuilder; no bareCommand::new.curl JSON minifier (feat(curl): losslessly minify JSON response bodies #94) — intact:
IgnoredAnyvalidity gate + textual whitespace stripper both present.container injection — PASS: docker/kubectl keep user args in argv slots; no shell-string concatenation.
panics — clean across all 8 files;
from_utf8_lossyused for arbitrary command output.git addno-bloat/synthetic-baseline (git add: tracking records -1300% savings (filter adds info to silent command) #89/filters: universal no-bloat guard — never emit output larger than raw #95) — confirmed not regressed.G4 — git + cloud command filters
thehoff commentedon May 20, 2026
G5 — system + rust + js command filters — findings (3 Codex passes)
No CRITICAL. 8 IMPORTANT, 2 NICE.
IMPORTANT
cmds/system/ls.rs:22— user path args split on leading-dash and forwarded tolsunchanged; a path like-laor-Rbecomes anlsoption. Fix: insert--before path operands.cmds/system/tree.rs:27— same path-as-flag injection, no--boundary before user paths.cmds/system/env_cmd.rs:136— env masking is real but incomplete: key-substring matching only. A secret under an innocuous key name (DATABASE_URL, connection strings) prints raw. Fix: value-aware redaction (scan values for token/password/URL-cred patterns).cmds/rust/cargo_cmd.rs(utils.rs:988,cargo_cmd.rs:93,168,1091) —strip_ansi()is NOT applied before failure-pattern matching, andsecure_cargo_command()doesn't setCARGO_TERM_COLOR=never. If coloured cargo output is forced, ANSI wrapserror:/FAILED→ prefix match breaks → a real failure reads as success. Fix: setCARGO_TERM_COLOR=neverinsecure_cargo_command()(one-liner) or strip ANSI before matching.cmds/rust/cargo_cmd.rs:1148—line[bracket_start+1..bracket_end]panics when[sits after](possible in ANSI-tainted lines). Fix: guardbracket_start < bracket_end, fall through to raw line.cmds/js/prettier_cmd.rs:79-93—filter_prettier_output()emits "Prettier: All files formatted correctly" for ANY output not matching its filename heuristics — including Prettier parse/config errors. Fix: gate the success string on exit code 0 AND a known marker.cmds/js/npm_cmd.rs:147,cmds/js/pnpm_cmd.rs:481— install paths drop allnpm WARN/notice/audit lines; a suspicious lifecycle/postinstall warning from a malicious package is silently swallowed. Fix: surface allWARN/notice/auditlines for install subcommands.cmds/js/prisma_cmd.rs:359-362—unwrap_or(20)slice offset can exceed line length → char-boundary panic. Fix: bounded.get().NICE-TO-HAVE
cmds/system/json_cmd.rs:25— stalertk read/rtk depsin error strings.cmds/rust/cargo_cmd.rs:1205—filter_cargo_clippycaps error blocks at 10; findings beyond the cap silently dropped. Raise/remove the cap (correctness, given "failures never sacrificed").Confirmed clean / PASS
grep forbidden-args — COVERED:
check_forbidden_rg_argsapplied atgrep_cmd.rs:37and therun_grep_format_passthroughsite; no bypass.find -exec— BLOCKED:-exec/-deletedenylisted;-fprintf/-okfall to the unknown-flag drop path. RCE surface closed.cargo hardened builder — PASS: all production spawns via
secure_cargo_command; no bareCommand::new("cargo").js hardened builder — PASS: every
cmds/js/spawn viasecure_node_command/package_manager_exec;NODE_OPTIONS/NODE_PATH/NPM_CONFIG_*stripped.js failure surfacing — PASS: vitest/jest/tsc/eslint propagate exit codes; no false-success on test/type/lint failures (prettier is the exception — finding 6).
pipe_cmd.rs— arg-list assembly, no shell string.local_llm.rs— parser-only, no subprocess/network.json_cmd.rs— propagates parse errors, no panic.cargo exit codes flow
run_streaming→run→mainintact.G5 — system + rust + js command filters
thehoff commentedon May 20, 2026
G6 — python/ruby/go/jvm/dotnet command filters — findings (3 Codex passes)
CRITICAL
core/utils.rs:2619—_JAVA_OPTIONSmissing fromJVM_DANGEROUS_ENVS. The list isJAVA_OPTS, JAVA_TOOL_OPTIONS, JDK_JAVA_OPTIONS, GRADLE_OPTS, GRADLE_USER_HOME._JAVA_OPTIONS(leading underscore — a distinct, undocumented JVM var) injects JVM args = code-exec, and is not stripped bysecure_jvm_command. The unit test atutils.rs:3104also omits it. Verified against source — note: the G1 pass (G1a) wrongly reportedsecure_jvm_commandas covering_JAVA_OPTIONS; it does not. Fix: add_JAVA_OPTIONSto the const AND the test.cmds/dotnet/binlog.rs:288,cmds/dotnet/dotnet_trx.rs:94— binlog/trx files read wholesale with no size cap (fs::read+GzDecoder::read_to_end/read_to_string). A hostile/malformed.binlogor.trx→ unbounded heap growth (OOM/DoS). Fix: size cap (e.g. 256 MB) before decompress/parse.cmds/dotnet/dotnet_cmd.rs:851,1028— dotnet build success inferred from the English text markerBuild succeeded/0 Warning(s) 0 Error(s). A non-zero exit that still emits that text can render asok. Fix: process exit code authoritative; text advisory only, discarded when it contradicts the exit code.IMPORTANT
core/utils.rs:2662—GOENVabsent fromGO_DANGEROUS_ENVS(gohonours it as a config-file pointer that can setGOFLAGSetc.). Fix: addGOENV(verify dangerousness at fix time).core/stream.rs:307-391— go/gradle filter predicates fed raw lines, no ANSI strip → coloured failure markers evade compaction (same class as the cargo finding G5). Fix: strip ANSI beforefeed_line()/filter_fn().cmds/python/pytest_cmd.rs:63,cmds/ruby/rspec_cmd.rs:165,cmds/ruby/rubocop_cmd.rs:109— failure-pattern matching on un-stripped stdout; ANSI-wrappedFAILURES/Failures:/offense markers evade detection → a failing run misreported as passing. Fix: strip ANSI before parsing, or pass--no-color/-p no:terminal.cmds/go/golangci_cmd.rs:179-228—find_subcommand_index()only skips values for a hard-coded global-flag subset; unknown separate-value flags misclassified, their values silently dropped. Fix: complete the value-flag table or use real CLI parsing.cmds/dotnet/dotnet_cmd.rs:261— temp-file prefixesrtk_dotnet_*surface in verbose/cleanup output. Fix: rename tocontextcrawler_*.Corrected — NOT a finding
rake/rubocop/rspec) bypassingsecure_ruby_command. False positive — verified against source:ruby_exec(utils.rs:270) internally wrapssecure_ruby_command, soRUBYOPT/RUBYLIB/GEM_HOMEARE stripped on those paths.Confirmed clean / PASS
Python hardened builders — PASS: all python-tool spawns via
secure_python_command(PYTHONPATH/PYTHONSTARTUP/PYTHONHOME/PYTHONINSPECTstripped).Ruby hardened builders — PASS (per the correction above).
DOTNET_STARTUP_HOOKS— PASS: stripped bysecure_dotnet_command.dotnet direct-indexing — all guarded by prior length checks; no reachable panic.
go/jvm — no reachable panics; no user-facing
rtkbranding (go/jvm).G6 — python/ruby/go/jvm/dotnet command filters
thehoff commentedon May 20, 2026
G7 — discover / analytics / learn / parser — findings (3 Codex passes)
CRITICAL
discover/registry.rs:399-400,734-744—RTK_DISABLEDbypass via substring match. The "is RTK disabled" check substring-searches the whole env-prefix chunk of a command. A crafted prefix likeFOO=RTK_DISABLED=1 git statusdisables rewriting — and therefore the permission/rewrite gates that ride on the hook — without genuinely settingRTK_DISABLED. A prompt-injected agent can prepend that to slip a command past the proxy. Fix: parse env assignments token-by-token; only honour a key named exactlyRTK_DISABLED.IMPORTANT
discover/registry.rs:378-397,269-274,817-819—strip_absolute_path()strips ANY first token containing/, not just true absolute paths../git,repo/bin/git, any relative wrapper → normalised togitand rewritten as the real binary — a semantic substitution the command didn't ask for. Fix: only strip when the token starts with/.discover/provider.rs:88-124—read_dir()entries trusted viapath.is_dir(), which is true for symlinked dirs. A symlinked project dir under~/.claude/projects/redirectsdiscoverscanning outside that tree. Fix:symlink_metadata().is_symlink()reject, then canonicalise + prefix-check.discover/codex.rs:109-122—reader.lines().map_while(|l| l.ok())silently stops at the first I/O/UTF-8 error and drops the rest of the log → undercount from one bad byte. Fix: explicit per-line error handling, keep iterating.analytics/gain.rs:262,725,745+analytics/session_cmd.rs:113— byte-slice truncation (&s[..n]) on user-controlled command/history strings; a multibyte char split at a byte boundary panics and killscontextcrawler gain. Fix: char-safe truncation (chars().take(n)).NICE-TO-HAVE
discover/report.rs:123-243— user-facing headings + the issue URLgithub.com/rtk-ai/rtk/issuesstillRTK-branded.analytics/cc_economics.rs:436,analytics/session_cmd.rs:186—rtk commands/rtk discoverin user-facing copy.Confirmed clean / PASS
lexer.rs— PASS: shell tokeniser handles unbalanced quotes / nested$(...)/ heredocs / huge input — no panic, no infinite loop, no ReDoS.Rewrite classification — clean (apart from findings 1-2): no semantic-merge/split hazard found in
rewrite_command.reconcile.rs— clean: SQLite openedREAD_ONLY; locked/corrupt DB → warning banner; UTC-consistent; tie-break panic-free.SQL — PASS: all
analytics/trackingqueries viarusqlite::params!; no string-built SQL; corrupt/missing DB → gracefulErr.discoverJSONL parse — clean: line-by-line, malformed lines skipped, no OOM.learn/+parser/— clean: no persistence writes, no ReDoS, no panic on odd input.No reachable non-test panics in
discover/(apart from thegainbyte-slice in finding 5).G7 — discover / analytics / learn / parser
thehoff commentedon May 20, 2026
G8 — TOML filter configs + test harness — findings (2 Codex passes)
IMPORTANT
match_outputfilters lack anunlessguard —brew-install,bundle-install,composer-install,dotnet-build,poetry-install,quarto-render,tofu-validate,uv-sync. Amatch_outputrule rewrites the displayed output to a fixed success message; without anunlessguard coveringerror|warning|failed|fatal, a partially-failed run whose output still contains the success pattern is shown to the agent as clean. (Graded IMPORTANT not CRITICAL: the exit code still propagates honestly — only the text an LLM agent reads is misleading.quarto-render's"Output created:"is the sharpest — it co-occurs with errors;dotnet-build's0 Error(s)is the mildest — unlikely in a failed run.) Fix: add anunlessguard to each.oxlint.toml:8,helm.toml:7—strip_lines_matchingregexes erase warning-summary lines (^Found \d+ warning,^W\d{4}), so a warnings-only run collapses to empty/clean. Fix: keep warning summaries.tests/cloud_hardening.rs— sharedcc-hardening-<pid>.sqliteDB across tests; order-dependence risk if a future assertion reads DB state. Fix: per-test tempRTK_DB_PATH.NICE-TO-HAVE
gradle.toml,pio-run.toml,tofu-plan.toml,xcodebuild.toml— success-ishon_emptymessages also fire when the tool crashes with no stdout. Consider gating on exit code.Test-harness verdicts (the meta-question: does the suite protect what it claims?)
cargo_hardening,node_hardening,git_hardening,cloud_hardening,runtime_hardening,gh_glab_gt_hardeningall spawn the actual binary and inspect the child env/output. The env-strip gaps this audit found (_JAVA_OPTIONS,NODE_PATH,CARGO_ENCODED_RUSTFLAGS) survived because the vars were never added to the strip list — the tests faithfully test an incomplete list. Adding the var to the list + the test's expected-set closes each.branding_lint.rsgap = overbroad allowlist. File-scan scope is correct (walks allsrc/**/*.rs). But stalertkstrings ingit.rs/container.rs/report.rs/hook_cmd.rswere explicitly exempted viaKNOWN_UNBRANDED_TEXT_NEEDLES/HOOK_PROTOCOL_NEEDLES/ permissive file-buckets — exemptions added to quiet rebrand-era false positives are now eating real violations. Fix: narrow exemptions to exact strings, not file-scope buckets. (Open issues harden(branding-lint): clap-aware sub-rule to catch /// doc-comment leaks before they reach --help #75/harden(branding-lint): shrink KNOWN_UNBRANDED_TEXT_NEEDLES debt list (70 → ≤20) #76 already track branding-lint hardening.)GAPs — bug classes the suite would NOT catch
harness_claude_code.rs— no test for a malformed/missing-field hook payload (the fail-open CRITICAL from G2 existed precisely because this wasn't tested).harness_standalone.rs— exercises direct commands only, never the hook payload path.proxy_nudge.rs— no OsString/shell-split edge cases (spaces, unicode, empty args) — the proxy CRITICAL from G2.cloud_hardening.rs— shared-DB state leak (also finding 3).G8 — TOML filter configs + test harness
thehoff commentedon May 20, 2026
AUDIT COMPLETE — consolidated summary (all 8 groups)
Full-codebase Codex audit, ~78k LOC, 24 review passes. Tallies below count post-correction (two inter-pass contradictions were resolved against source — see G6).
Findings by group
CRITICALs still open (G3–G8 — need fix branches)
-K=filedeny-list bypass (attached-value form); wget gate misses-O/-i/--load-cookiesentirely._JAVA_OPTIONSmissing from JVM env strip; dotnet binlog/trx parsed with no size cap (OOM); dotnet build success inferred from English text marker (non-zero exit can renderok).RTK_DISABLEDdetected by substring over the env-prefix chunk →FOO=RTK_DISABLED=1 git statusbypasses the rewriter + gates.Two items needing a product/design decision (not auto-fixable)
tirith_gate/supply_chain_gatefire only oncontextcrawler rewrite, nothook claude. Wire them in, or formally document them as opt-in-only.maybe_ping()phones home (gated, opt-out works, first-word-only command aggregates, no secrets/argv). Given the local-first posture: keep gated, default-off, or strip from the fork.Cross-cutting themes the audit surfaced
_JAVA_OPTIONS,NODE_PATH,CARGO_ENCODED_RUSTFLAGS,GOENV) are simply missing list entries. A single "known dangerous env" registry with a completeness test would prevent recurrence.match_outputwithoutunless— 8 TOML filters can show a misleading success message (exit code stays honest).rtkstrings exempted alongside false positives.What's confirmed SOLID
SQL injection (bound params), secret scrubbing before persist, ReDoS (linear-time regex), filter pipeline has no code-execution, trust gate + permissions fail-closed, 14/17
secure_*env builders airtight, lexer robust, git/gh/glab/cloud command construction uses hardened builders, no reachable panics on most hot paths.All 8 groups checked above. G3–G8 fix branches to follow.
Merge pull request #103 from thehoff/harden/g8-audit-100
Merge pull request #104 from thehoff/harden/g7-audit-100
Merge pull request #105 from thehoff/harden/g6-audit-100
Merge pull request #106 from thehoff/harden/gate-wiring-100
Merge pull request #107 from thehoff/harden/g4-audit-100
Merge pull request #108 from thehoff/harden/g3-audit-100
4 remaining items
harden(hooks): fix fail-open + injection findings (thehoff#100 G2)
harden(hooks): close fail-open + path-traversal holes (thehoff#100 G2…
fix(filters): harden TOML filter unless-guards + test isolation (G8 t…
fix(discover/analytics): harden G7 audit findings (thehoff#100)
fix(security): harden git + cloud command filters (G4 thehoff#100)
harden: G3 filter-engine/tracking audit + disable network telemetry
harden(g6): close python/ruby/go/jvm/dotnet filter audit findings (th…
harden(hooks): wire defence-in-depth gates into the live Claude hook …
fix(discover): reject symlinked session files in project walk (thehof…
fix(security): Codex-review second pass — short-flag bundle/attached-…
harden(g6): spawn-verify env strip + document ANSI no-regression (the…
harden(hooks): Codex-review follow-up for the gate-wiring portion of t…
Codex-review follow-up for the G3 portion of thehoff#100 — stream dea…
harden(system): env/ls/tree path-flag boundary + entropy-based secret…
fix(system): grep -- argument boundary; tree -o + find path-relative …