Skip to content

fix(build-tools): Go forbidden-arg checker + close pytest/gradle/golangci config bypasses (#111 G6) - #118

Merged
thehoff merged 2 commits into
developfrom
fix/g6-audit-111
May 20, 2026
Merged

thehoff merged 2 commits into
developfrom
fix/g6-audit-111

Conversation

@thehoff

@thehoff thehoff commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the G6 findings from the independent Claude review (#111). The #100 audit hardened the env-injection surface but left the command-line forbidden-flag surface inconsistent.

Findings fixed

Sev Fix
CRITICAL Go had no forbidden-arg checker — go build -toolexec=/tmp/evil, go test -exec /x, -gcflags=-toolexec=... all ran an arbitrary binary (RCE). New check_forbidden_go_args rejects -toolexec/-exec (exact + attached) and -gcflags/-ldflags/-asmflags values that smuggle them. Wired into every go_cmd.rs run_* and golangci_cmd.rs. The false "secure_go_command defends -toolexec" comment is corrected.
IMPORTANT pytest -c/--config bypassed the -p plugin block (an attacker pytest.ini sets addopts = -p <plugin>) — now rejected.
IMPORTANT gradle -I glued form (-I/path/init.gradle) + -c/--settings-file, -b/--build-file (arbitrary Groovy) — now rejected.
IMPORTANT golangci-lint -c/--config (can point at a custom Go-plugin .so) — now rejected.

Test plan

  • New tests in tests/runtime_hardening.rs — -toolexec/-exec/-gcflags smuggling rejected, plain go build works, pytest/gradle/golangci config flags rejected
  • CI verifies the full cargo test --workspace (local run skipped — machine under heavy multi-worktree build load)
  • Codex review to follow

Part of the #111 audit.

🤖 Generated with Claude Code

thehoff and others added 2 commits May 20, 2026 22:13
…111 G6 follow-up)

Go's flag parser accepts one OR two leading dashes for every flag, so
`go build --toolexec=/x`, `--gcflags=-toolexec=/x` and `--exec /x`
bypassed the single-dash-only deny helper — full RCE.

Canonicalize a double-dash flag token to single-dash form for matching
only (the checker inspects argv, never rewrites it). A bare `--`
end-of-options separator is left intact; only one dash is stripped so
`---x` never collapses past a single dash. All existing checks
(-toolexec/-exec exact + attached, -gcflags/-ldflags/-asmflags value
smuggling) now catch both `-` and `--` forms with no duplication.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thehoff
thehoff merged commit 4c22b25 into develop May 20, 2026
3 checks passed
@thehoff
thehoff deleted the fix/g6-audit-111 branch May 20, 2026 13:14
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.

1 participant