Repository navigation
Fix command-line argument injection in Diff action (CVSS 8.6) - #29
Merged
Merged
Conversation
A crafted filename such as "payload --extcmd=wscript.exe" was interpolated unquoted into the git difftool argument string. Since ProcessStartInfo.Arguments is parsed as a whitespace-delimited command line, the filename split into two arguments, letting git interpret --extcmd (or --ext-diff/-x) as a real option and execute an attacker-chosen program with the victim's privileges when they clicked Diff on a crafted repository. Fix by quoting the path arguments and inserting -- before them so git always treats them as positional paths, never as options. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Extract the difftool argument-building logic into GitHelpers.BuildDiffToolArguments so it is unit-testable without pulling WPF dependencies into the test project, and add tests that exercise the crafted-filename payload from the report (e.g. "payload --extcmd=wscript.exe") to confirm it is always kept as a single quoted, positional path after '--' and never parsed as a git option. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.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.
Summary
Fixes a command-line argument injection vulnerability in the Diff action (
DiffFileChangeAction) that let a crafted repository execute arbitrary programs on the victim's machine.Vulnerability
git difftoolwas invoked with a path built by directly interpolating the file's name into the argument string, unquoted:ProcessStartInfo.Argumentsis parsed like a shell command line. A file (or renamed-from path) named, e.g.,payload --extcmd=wscript.exewould split into two arguments once whitespace-delimited:payloadand--extcmd=wscript.exe. Git then parses the latter as a real--extcmdoption, running an attacker-chosen program with the victim's OS privileges — triggered simply by opening the crafted repo and clicking the normal Diff button.Fix
--before the paths so git treats everything after it as positional paths, never options — defense in depth even if quoting were somehow bypassed.GitHelpers.BuildDiffToolArguments(Core project) so it's unit-testable independent of the WPF UI project.Testing
Added
GitTimelapseView.Tests/GitHelpersTests.cswith regression tests, including one using the exact payload from the report (payload --extcmd=wscript.exe), asserting the malicious text always stays inside a single quoted path placed after--.dotnet test GitTimelapseView.Tests/GitTimelapseView.Tests.csproj→ 5/5 passeddotnet build GitTimelapseView/GitTimelapseView.csproj→ build succeeded, 0 warnings/errors🤖 Generated with Claude Code