Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/goto-diff/scripts/diff-filter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
{
if($edits{$f}{$l} =~ /^[CDcd]$/)
{
`sed -i '${l}s/^/$edits{$f}{$l}#/' $f_edit`;
`sed -i.bak '${l}s/^/$edits{$f}{$l}#/' $f_edit`;
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backtick-executed sed command interpolates $f_edit directly into a shell command without quoting or escaping, which allows shell metacharacters in file names from the goto-diff output to break out of the sed invocation and run arbitrary commands. An attacker controlling a file path in the diff (for example via a repository with crafted file names) can trigger command execution when this script is run. Use a safer invocation that avoids the shell (such as Perl’s system in list form or a pure-Perl edit) or ensure $f_edit is safely quoted/escaped so that any metacharacters are treated as literal path characters, not shell syntax.

Copilot uses AI. Check for mistakes.
unlink "$f_edit.bak";
}
}
}
Expand Down
Loading