Repository navigation
fix(build-tools): Go forbidden-arg checker + close pytest/gradle/golangci config bypasses (#111 G6) - #118
Merged
Conversation
…olangci config bypasses (#111 G6)
…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]>
Closed
8 tasks done
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 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
go build -toolexec=/tmp/evil,go test -exec /x,-gcflags=-toolexec=...all ran an arbitrary binary (RCE). Newcheck_forbidden_go_argsrejects-toolexec/-exec(exact + attached) and-gcflags/-ldflags/-asmflagsvalues that smuggle them. Wired into everygo_cmd.rsrun_*andgolangci_cmd.rs. The false "secure_go_command defends -toolexec" comment is corrected.-c/--configbypassed the-pplugin block (an attacker pytest.ini setsaddopts = -p <plugin>) — now rejected.-Iglued form (-I/path/init.gradle) +-c/--settings-file,-b/--build-file(arbitrary Groovy) — now rejected.-c/--config(can point at a custom Go-plugin.so) — now rejected.Test plan
tests/runtime_hardening.rs—-toolexec/-exec/-gcflagssmuggling rejected, plaingo buildworks, pytest/gradle/golangci config flags rejectedcargo test --workspace(local run skipped — machine under heavy multi-worktree build load)Part of the #111 audit.
🤖 Generated with Claude Code