Skip to content

Commit 4e7e3b7

Browse files
j6tttaylorr
authored andcommitted
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. Signed-off-by: Johannes Sixt <[email protected]>
2 parents 664d4fa + 8e3070a commit 4e7e3b7

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

gitk-git/gitk

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,6 @@ proc parseviewrevs {view revs} {
353353
return $ret
354354
}
355355

356-
# Escapes a list of filter paths to be passed to git log via stdin. Note that
357-
# paths must not be quoted.
358-
proc escape_filter_paths {paths} {
359-
set escaped [list]
360-
foreach path $paths {
361-
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
362-
}
363-
return $escaped
364-
}
365-
366356
# Start off a git log process and arrange to read its output
367357
proc start_rev_list {view} {
368358
global startmsecs commitidx viewcomplete curview
@@ -424,8 +414,7 @@ proc start_rev_list {view} {
424414
if {[catch {
425415
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
426416
--parents --boundary $args --stdin \
427-
"<<[join [concat $revs "--" \
428-
[escape_filter_paths $files]] "\\n"]"] r]
417+
[list "<<[join [concat $revs "--" $files] "\n"]"]] r]
429418
} err]} {
430419
error_popup "[mc "Error executing git log:"] $err"
431420
return 0
@@ -578,9 +567,7 @@ proc updatecommits {} {
578567
if {[catch {
579568
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
580569
--parents --boundary $args --stdin \
581-
"<<[join [concat $revs "--" \
582-
[escape_filter_paths \
583-
$vfilelimit($view)]] "\\n"]"] r]
570+
[list "<<[join [concat $revs "--" $vfilelimit($view)] "\n"]"]] r]
584571
} err]} {
585572
error_popup "[mc "Error executing git log:"] $err"
586573
return
@@ -10258,7 +10245,7 @@ proc getallcommits {} {
1025810245
if {$ids eq "--all"} {
1025910246
set cmd [concat $cmd "--all"]
1026010247
} else {
10261-
set cmd [concat $cmd --stdin "<<[join $ids "\\n"]"]
10248+
set cmd [concat $cmd --stdin [list "<<[join $ids "\n"]"]]
1026210249
}
1026310250
set fd [open $cmd r]
1026410251
fconfigure $fd -blocking 0

0 commit comments

Comments
 (0)