Skip to content

fix(cli): scope headless git credentials - #167

Merged
BunsDev merged 2 commits into
mainfrom
codex/fix-unscoped-git-helper-vulnerability
Jul 27, 2026
Merged

fix(cli): scope headless git credentials#167
BunsDev merged 2 commits into
mainfrom
codex/fix-unscoped-git-helper-vulnerability

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 26, 2026

Copy link
Copy Markdown
Member

Motivation

  • The headless runtime previously installed an unscoped Git credential helper that returned COVEN_GIT_TOKEN for any get request, allowing token exfiltration to attacker-controlled HTTPS remotes.
  • The change confines credential responses to the existing origin GitHub https://github.com/<owner>/<repo> remote and enables path-aware lookups to prevent accidental disclosure.

Description

  • Add origin parsing and quoting helpers (origin_github_repo_path, github_repo_path_from_url, shell_single_quote) and require an origin GitHub path before installing a helper.
  • Replace the unconditional helper with a shell snippet that parses Git's stdin (protocol, host, path) and only emits credentials when protocol=https, host=github.com, and path matches the repo owner/repo (accepting an optional .git suffix).
  • Enable credential.useHttpPath = true so Git passes repository paths to the helper, allowing the helper to reject non-origin requests.
  • Add regression tests that assert the helper references $COVEN_GIT_TOKEN (not the literal token), that the helper is scoped to the origin path, that useHttpPath is set, and that the helper does not return the token for attacker-controlled credential requests.

Testing

  • Ran cargo fmt --all successfully.
  • Ran cargo test --package claurst --no-default-features configure_git_auth -- --nocapture, and the headless configure_git_auth unit tests passed.
  • Ran cargo check --workspace --no-default-features, which succeeded.
  • cargo check --workspace failed in this environment due to a missing system dependency (alsa.pc) unrelated to this change.
  • cargo clippy --workspace --all-targets --no-default-features -- -D warnings failed due to pre-existing clippy::collapsible_if warnings in crates/tui/src/image_paste.rs, which are outside the scope of this fix.

Codex Task

Copilot AI review requested due to automatic review settings July 26, 2026 17:09
@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jul 27, 2026 12:12pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the headless CLI’s Git authentication by scoping the installed credential helper so it only returns COVEN_GIT_TOKEN for the repository’s existing origin https://github.com/<owner>/<repo> remote (and enabling path-aware lookups to prevent token disclosure to other HTTPS remotes).

Changes:

  • Parse and require a GitHub origin repo path before installing the credential helper.
  • Replace the unconditional helper with a stdin-parsing helper that checks protocol=https, host=github.com, and matching path (with optional .git).
  • Add regression tests asserting the helper remains env-backed, is scoped to origin, enables credential.useHttpPath, and rejects attacker-controlled credential requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-rust/crates/cli/src/headless.rs Outdated
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
@BunsDev
BunsDev merged commit f37207b into main Jul 27, 2026
4 checks passed
@BunsDev
BunsDev deleted the codex/fix-unscoped-git-helper-vulnerability branch July 27, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants