Skip to content

fix: awk injection vulnerability in get_worktree_path#5

Merged
RodrigoEspinosa merged 1 commit intomasterfrom
security-fix-awk-injection-1842531871741686573
Apr 11, 2026
Merged

fix: awk injection vulnerability in get_worktree_path#5
RodrigoEspinosa merged 1 commit intomasterfrom
security-fix-awk-injection-1842531871741686573

Conversation

@RodrigoEspinosa
Copy link
Copy Markdown
Owner

🎯 What: The vulnerability fixed
Using awk -v b="$branch" in get_worktree_path allowed awk to evaluate escape sequences in the $branch variable, leading to AWK injection if the branch name contained backslashes.

⚠️ Risk: The potential impact if left unfixed
An attacker or malicious repository could use specially crafted branch names with backslashes to trigger unexpected behavior or execute unintended logic when awk processes the input, potentially exposing the user to command injection or unauthorized data access.

🛡️ Solution: How the fix addresses the vulnerability
Replaced the vulnerable -v variable assignment with an environment variable approach. Specifically, used BRANCH="$branch" awk -F'\t' '$1 == ENVIRON["BRANCH"] { print $2 }'. This ensures awk treats the input as a literal string without evaluating embedded escape sequences. Added a BATS test to confirm proper handling of backslashes in branch names.


PR created automatically by Jules for task 1842531871741686573 started by @RodrigoEspinosa

@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@RodrigoEspinosa RodrigoEspinosa changed the title 🔒 Fix AWK injection vulnerability in get_worktree_path fix: awk injection vulnerability in get_worktree_path Apr 11, 2026
Replaced the vulnerable `-v b="$branch"` awk variable assignment with
an environment variable approach `BRANCH="$branch" awk ... ENVIRON["BRANCH"]`
to prevent awk from evaluating escape sequences in branch names.
Added a BATS test to verify correct handling of backslashes.

Co-authored-by: RodrigoEspinosa <1685621+RodrigoEspinosa@users.noreply.github.com>
@RodrigoEspinosa RodrigoEspinosa force-pushed the security-fix-awk-injection-1842531871741686573 branch from 1d41ca8 to 02fab9f Compare April 11, 2026 18:13
@RodrigoEspinosa RodrigoEspinosa merged commit ce9d874 into master Apr 11, 2026
@RodrigoEspinosa RodrigoEspinosa deleted the security-fix-awk-injection-1842531871741686573 branch April 11, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant