Skip to content

Commit 0c8be6f

Browse files
committed
Merge branch 'ah/fix-open-with-stdin'
This addresses CVE-2025-27614, Arbitrary command execution with Gitk: A Git repository can be crafted in such a way that with some social engineering a user who has cloned the repository can be tricked into running any script (e.g., Bourne shell, Perl, Python, ...) supplied by the attacker by invoking `gitk filename`, where `filename` has a particular structure. The script is run with the privileges of the user. * ah/fix-open-with-stdin: gitk: encode arguments correctly with "open" Signed-off-by: Johannes Sixt <[email protected]>
2 parents bfb0fa7 + 8e3070a commit 0c8be6f

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

gitk

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,6 @@ proc parseviewrevs {view revs} {
457457
return $ret
458458
}
459459
460-
# Escapes a list of filter paths to be passed to git log via stdin. Note that
461-
# paths must not be quoted.
462-
proc escape_filter_paths {paths} {
463-
set escaped [list]
464-
foreach path $paths {
465-
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
466-
}
467-
return $escaped
468-
}
469-
470460
# Start off a git log process and arrange to read its output
471461
proc start_rev_list {view} {
472462
global startmsecs commitidx viewcomplete curview
@@ -528,8 +518,7 @@ proc start_rev_list {view} {
528518
if {[catch {
529519
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
530520
--parents --boundary $args --stdin \
531-
"<<[join [concat $revs "--" \
532-
[escape_filter_paths $files]] "\\n"]"] r]
521+
[list "<<[join [concat $revs "--" $files] "\n"]"]] r]
533522
} err]} {
534523
error_popup "[mc "Error executing git log:"] $err"
535524
return 0
@@ -682,9 +671,7 @@ proc updatecommits {} {
682671
if {[catch {
683672
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
684673
--parents --boundary $args --stdin \
685-
"<<[join [concat $revs "--" \
686-
[escape_filter_paths \
687-
$vfilelimit($view)]] "\\n"]"] r]
674+
[list "<<[join [concat $revs "--" $vfilelimit($view)] "\n"]"]] r]
688675
} err]} {
689676
error_popup "[mc "Error executing git log:"] $err"
690677
return
@@ -10376,7 +10363,7 @@ proc getallcommits {} {
1037610363
if {$ids eq "--all"} {
1037710364
set cmd [concat $cmd "--all"]
1037810365
} else {
10379-
set cmd [concat $cmd --stdin "<<[join $ids "\\n"]"]
10366+
set cmd [concat $cmd --stdin [list "<<[join $ids "\n"]"]]
1038010367
}
1038110368
set fd [open $cmd r]
1038210369
fconfigure $fd -blocking 0

0 commit comments

Comments
 (0)