Repository navigation
harden(jvm/go/dotnet): _JAVA_OPTIONS strip, binlog OOM cap, dotnet exit-code authority (#100 G6) - #105
Merged
Conversation
… G6) Addresses the G6 group of the full-codebase audit in issue #100. CRITICAL 1 — JVM env strip missing _JAVA_OPTIONS: core/utils.rs JVM_DANGEROUS_ENVS gained "_JAVA_OPTIONS", the distinct undocumented HotSpot var that prepends JVM args at startup (a code-exec vector separate from JAVA_OPTS / JAVA_TOOL_OPTIONS). Unit test jvm_command_lists_cover_known_vectors extended; added secure_jvm_command_strips_underscore_java_options asserting it is env_remove()'d from the spawned child of every JVM builder. CRITICAL 2 — unbounded .binlog/.trx reads: binlog.rs gained MAX_ARTIFACT_BYTES (256 MiB) and read_capped(), which rejects oversize files from filesystem metadata BEFORE allocating. The binlog gzip payload is also capped via Read::take (gzip-bomb defence: a tiny file can inflate to gigabytes). dotnet_trx.rs gained read_trx_capped() applied to both read sites. Tests added for oversize rejection and within-cap acceptance. CRITICAL 3 — dotnet build success inferred from English text: normalize_build_summary now treats the process exit code as authoritative: a non-zero exit forces succeeded=false, overriding any "Build succeeded" / "0 Warning(s) 0 Error(s)" text marker the binlog parser may have set. Regression test confirms the verdict renders "fail", never "ok", on a non-zero exit. IMPORTANT 4 — GOENV missing from GO_DANGEROUS_ENVS: GOENV points `go` at an alternate env config file that can set GOFLAGS/GOPROXY/CC — an indirect path to every Go vector already stripped. Added; test list extended; child-env strip test added. IMPORTANT 5 — cargo ANSI env companion: secure_cargo_command() now sets CARGO_TERM_COLOR=never so cargo output is never ANSI-coloured (env-side companion to the G5 cargo ANSI fix). Test secure_cargo_command_forces_term_color_never added. IMPORTANT 6 — failure-pattern matching on un-stripped stdout: pytest/rspec/rubocop filters strip ANSI before the matching state machine, so colour codes wrapping failure markers can no longer evade detection. ANSI-wrapped-failure regression tests added for all three. IMPORTANT 7 — golangci global-flag mis-parse: find_subcommand_index now bails to Passthrough on an unrecognised global flag rather than guessing whether it consumes the next arg — a wrong guess could misclassify the real subcommand. Added a GLOBAL_BOOL_FLAGS table so known boolean flags are still recognised. Regression test added. IMPORTANT 8 — temp-file branding: dotnet temp prefixes rtk_dotnet_* renamed to contextcrawler_dotnet_*; the now-dead branding_lint exemption removed. cargo test --workspace: 2305 passed, 6 ignored. cargo build --release clean, no new warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codex-review follow-up for the G6 portion of #100. Finding 1 — env-strip tests were structural only: The G6 commit asserted _JAVA_OPTIONS / GOENV appear in removed_env_names(&secure_*_command(...)) — it inspected Command::get_envs() but never confirmed the var is absent from a real child's environment. Added two spawn-and-verify unit tests (secure_jvm_command_strips_underscore_java_options_in_child, secure_go_command_strips_goenv_in_child): each sets the var in the process env, builds the command via the real secure_*_command builder pointed at /usr/bin/env (which resolves an absolute path to itself, yielding a genuine hardened spawnable Command), spawns it, and asserts the var is genuinely absent from the child's printed environment. Mirrors the spawn-and-verify model of tests/runtime_hardening.rs / tests/cargo_hardening.rs. Finding 2 — ANSI strip and user-facing colour: assessed, no regression. pytest/rspec/rubocop filters all emit a fully synthesised compact summary (build_pytest_summary / build_rspec_summary / filter_rubocop_{json,text}) and never echo the tool's original lines verbatim — the tool's TTY colour was already discarded by the reformatting before the G6 strip was added. Stripping ANSI only affects the matcher's input; there is no original colour left to preserve, so no split matcher/display paths are warranted. Documented the no-regression rationale in a code comment at each of the three strip sites. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
8 tasks
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.
Summary
Fixes the G6 (python/ruby/go/jvm/dotnet filters) findings from audit #100. Codex-reviewed; review follow-ups applied.
Findings fixed
core/utils.rs—_JAVA_OPTIONS(a distinct undocumented HotSpot var that injects JVM args = code-exec) added toJVM_DANGEROUS_ENVS. The G1 audit pass wrongly reported this as already covered — it was not.cmds/dotnet/binlog.rs,dotnet_trx.rs—.binlog/.trxread with a 256 MiB cap (read_capped); the decompressed binlog payload also hard-bounded viaRead::take— gzip-bomb defence (a tiny file inflating to GB).cmds/dotnet/dotnet_cmd.rs— build success was inferred from English text (Build succeeded) andnormalize_build_summarynever resetsucceededto false; a non-zero exit could renderok. Process exit code is now authoritative.core/utils.rs—GOENVadded toGO_DANGEROUS_ENVS(it pointsgoat an alt env config file that can setGOFLAGS/GOPROXY/CC).core/utils.rs—secure_cargo_command()setsCARGO_TERM_COLOR=never(env-side companion to the cargo ANSI fix).cmds/go/golangci_cmd.rs—find_subcommand_indexbails to passthrough on an unrecognised global flag instead of mis-parsing/dropping values.rtk_dotnet_*temp prefixes →contextcrawler_dotnet_*.Codex review follow-up (
e996566)_JAVA_OPTIONS/GOENV(build the real hardened command, spawn a child, assert the var is absent from its environment) — the original tests were structural list-checks.Test plan
cargo test --workspace— 2307 pass, 0 failcargo build --releasecleanPart of the #100 audit.
🤖 Generated with Claude Code