gemaraproj / gemaraproj/grc-store-clientkit
provenance.Build unconditionally execs git in the caller's cwd; needs an opt-out or explicit source input
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
:robot: Found during a security review of privateerproj/privateer-sdk#296 (results publishing, since closed in favor of a pinned GitHub Action that will presumably use this same package, where the concerns below apply directly).
`provenance.Build` calls `detectGit()` unconditionally (provenance.go:108), which runs `git config --get remote.origin.url` and `git rev-parse HEAD` via `exec.Command` (provenance.go:200-206), resolved through PATH, in whatever directory the caller happens to run from, on every Build call. Three consequences, all traced through source:
1. **PATH-based code execution.** A hostile `git` earlier in PATH executes as the calling tool. Go's ErrDot hardening blocks a cwd-planted binary but not a writable PATH entry, which is a realistic condition in CI images, exactly where the pinned Action will run.
2. **Injection into a signed attestation.** A hostile repo in the cwd puts an arbitrary `remote.origin.url` string into the signed, Rekor-logged SLSA provenance as a resolved dependency. `stripUserinfo` handles credentials in URL-shaped remotes, but the value itself is attacker-chosen.
3. **Privacy and accuracy.** The attestation publicly embeds `$USER@hostname`, `GITHUB_*` values, and the cwd repo identity. For callers whose cwd is unrelated to the artifact being attested (any evaluator-style caller, unlike grcli publishing from its own source tree), the resolved-dependency claim is also semantically wrong.
Suggested fix: make git detection opt-in or add an explicit source input, e.g. a `DisableGitDetection bool` (or `Source *SourceRef`) on `provenance.Input`, so callers state what the provenance should claim instead of inheriting whatever repo the operator stood in. Bounding the subprocess with `exec.CommandContext` would also let callers cancel it.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in provenance.go at provenance.Build and trace detectGit() through the exec.Command calls around lines 108 and 200-206. Decide how Input should express an opt-out or explicit source, then verify that Build no longer inherits the caller's repository or runs Git unless requested, while preserving accurate provenance and allowing cancellation where supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100