Repository navigation
fix(git): GHSA-wvv2-676g-r57j - git_remote credential redaction bypassed by a tab in a remote name or a prefixed URL - #5674
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 14 | 2 | 0 | 0 |
| Head | 14 | 2 | 0 | 0 |
Updated by this run for 4eacdbb2b41aeedddc8161318f72613d568f5068.
Closes #5666
Fix for GHSA-wvv2-676g-r57j. It was written and reviewed in the advisory's private fork, where a subagent reviewer stood in for Copilot (which cannot review a private fork) until a clean round. Per the advisory flow this PR gets no Copilot review. The private fork has no Actions, so this PR's CI is the first CI run on the change; the full
npm run local:gatepassed on this exact head and on a rollup of all eight advisory fixes.Fix for GHSA-wvv2-676g-r57j (private fork; no public issue).
Description
git_remotecould return a credential from a URL in two ways:git remote -vprints<name> <url> (fetch), and the parser split each line on the first tab. A name such asc dmoved the column boundary, so the URL field becamed https://alice:TOKEN@.... That does not start withscheme://, soredact_urlreturned it unchanged. With a credential-bearingurl.<cred>.insteadOfin the user's global config, this returned the host user's token for a repository whose own config holds no secret at all.url = " https://bob:TOKEN@..."(leading whitespace).redact_urlreturned any value without a scheme at offset 0 unchanged.The fix, in
src/git/src/mcp_server_git/server.py:git_remotenow gets the configured remote names fromgit remote(one per line; git allows no newline in a remote name) and takes eachremote -vline's name as the longest configured name the line starts with, followed by a tab. The tab inside a name no longer shifts the URL column. A line that starts with no configured name is withheld (<redacted>), the same as an unparseable line today._REMOTE_LINEis replaced by_REMOTE_ENTRY, which parses only what follows<name>.redact_url: a value that has no scheme at its start but holdsscheme://anywhere (_EMBEDDED_URL) is withheld whole as<redacted>. The URL cannot be split safely from what comes before it. This also covers the ambiguous case where bothcandc dare configured, and the line really came fromcwith a URL that holds a tab. That URL is left holding a URL that does not start it, so it is withheld. A remote-helper prefix keeps working:https:: https://...becomeshttps::<redacted>.The output keeps the
git remote -vformat, insteadOf rewrites included, so existing clients see no change for ordinary remotes. I considered rebuilding the listing fromgit remote get-url --allper remote. It does not matchremote -v: it prints the remote's name as its URL for a remote with no URL, and it loses the promisor filter. So I keptremote -vand take the names from git's own listing instead.What this leaves open: a URL that does start with a scheme still keeps its path segments verbatim. That is unchanged and documented ("A token carried as a path segment ... is not redacted"). A remote name is shown as configured, and names are not URLs and are not redacted. Neither is reachable through an
insteadOfrewrite, which only rewrites a URL's prefix.Server Details
mcp-server-git, Python)git_remotetool output (redaction),redact_urlMotivation and Context
The README promises that "A credential embedded in a URL is never returned", and both cases above broke that promise. This is a sibling of the earlier newline fix (
_remote_url_has_newline, commit 20a1775), which is unchanged.How Has This Been Tested?
src/git/tests/test_remote.py), all failing onorigin/v2/mainand passing here:test_tab_in_remote_name_keeps_the_url_whole(protocol level): ac dremote with a globalinsteadOfthat carries a host token. The URL is redacted and the token is absent.test_url_not_starting_with_its_scheme_is_withheld(protocol level): a leading-space URL is withheld.test_longest_configured_name_is_matched: remotescandc dtogether, and a line whose name is not configured.test_redact_urlcases: leading space, a tab-prefixed value,x https://..., andhttps:: https://....test_unparseable_line_is_withheldwas updated to mock bothgit remoteandgit remote -v.t_remote.py, real server over an in-memory transport): before,alice:HOSTTOKENandbob:REPOTOKENwere returned. After, both are<redacted>.@modelcontextprotocol/inspector@2.12.0 --cli,git_remote,--repositoryset,GIT_CONFIG_GLOBALcarrying theinsteadOftoken), in both eras (--protocol-era legacyandmodern):c d https://alice:HOSTTOKEN@srv.example.com/org/r.git (fetch)… andlead https://bob:REPOTOKEN@example.com/r.git (fetch)…c d https://<redacted>@srv.example.com/org/r.git (fetch)… andlead <redacted> (fetch)…npm run local:gate: EXIT=0.Breaking Changes
None. Only values that hold a URL not at their start are now withheld, plus lines that start with no configured remote name.
git remote -vnever prints such a line for a configured remote.Types of changes
Checklist
git_remoteentry)🤖 Generated with Claude Code