🔒 [security fix] Fix Eval Injection in fish fzf preview - #3
Conversation
Properly escape $file_path using `string escape --` before passing it to `eval` in `_fzf_preview_file.fish`. This prevents arbitrary command execution when previewing files with malicious names.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Code Review
This pull request improves the security and reliability of file and directory previews in the Fish shell by replacing manual quoting with the string escape builtin within eval calls. The review feedback suggests further hardening these calls by using the -- flag with eval to ensure that command variables starting with a hyphen are not misinterpreted as options to the eval command itself.
| if set --query fzf_preview_file_cmd | ||
| # need to escape quotes to make sure eval receives file_path as a single arg | ||
| eval "$fzf_preview_file_cmd '$file_path'" | ||
| eval $fzf_preview_file_cmd (string escape -- "$file_path") |
There was a problem hiding this comment.
While the use of string escape correctly mitigates the injection vulnerability, eval can still misinterpret the command if $fzf_preview_file_cmd starts with a hyphen (e.g., if it's set to a command named -h). Using eval -- is a more robust practice to ensure that the variable's content is treated as the command to be executed rather than an option to the eval builtin.
eval -- $fzf_preview_file_cmd (string escape -- "$file_path")
| if set --query fzf_preview_dir_cmd | ||
| # see above | ||
| eval "$fzf_preview_dir_cmd '$file_path'" | ||
| eval $fzf_preview_dir_cmd (string escape -- "$file_path") |
🎯 What: Fixed an eval injection vulnerability in
⚠️ Risk: Arbitrary command execution if a filename contains special characters (e.g., single quotes).
_fzf_preview_file.fish.🛡️ Solution: Used
string escape --to properly escape the$file_pathbefore passing it toeval.PR created automatically by Jules for task 12480772281073399573 started by @phucisstupid