fix(cli): scope headless git credentials - #167
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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
originrepo path before installing the credential helper. - Replace the unconditional helper with a stdin-parsing helper that checks
protocol=https,host=github.com, and matchingpath(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.
Signed-off-by: Val Alexander <68980965+BunsDev@users.noreply.github.com>
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.
Motivation
COVEN_GIT_TOKENfor anygetrequest, allowing token exfiltration to attacker-controlled HTTPS remotes.originGitHubhttps://github.com/<owner>/<repo>remote and enables path-aware lookups to prevent accidental disclosure.Description
origin_github_repo_path,github_repo_path_from_url,shell_single_quote) and require anoriginGitHub path before installing a helper.protocol,host,path) and only emits credentials whenprotocol=https,host=github.com, andpathmatches the repoowner/repo(accepting an optional.gitsuffix).credential.useHttpPath = trueso Git passes repository paths to the helper, allowing the helper to reject non-origin requests.$COVEN_GIT_TOKEN(not the literal token), that the helper is scoped to the origin path, thatuseHttpPathis set, and that the helper does not return the token for attacker-controlled credential requests.Testing
cargo fmt --allsuccessfully.cargo test --package claurst --no-default-features configure_git_auth -- --nocapture, and the headlessconfigure_git_authunit tests passed.cargo check --workspace --no-default-features, which succeeded.cargo check --workspacefailed in this environment due to a missing system dependency (alsa.pc) unrelated to this change.cargo clippy --workspace --all-targets --no-default-features -- -D warningsfailed due to pre-existingclippy::collapsible_ifwarnings incrates/tui/src/image_paste.rs, which are outside the scope of this fix.Codex Task