Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix command injection in toolExists#57

Open
acebytes wants to merge 1 commit intomainfrom
sentinel/fix-command-injection-which-17173991696500172285
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix command injection in toolExists#57
acebytes wants to merge 1 commit intomainfrom
sentinel/fix-command-injection-which-17173991696500172285

Conversation

@acebytes
Copy link
Copy Markdown
Contributor

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Command injection vulnerability identified in toolExists within CacheCategory.swift. The method utilized a shell wrapper (/bin/bash -c) with string interpolation to pass dynamic arguments: shell("/usr/bin/which \(tool)").
🎯 Impact: While the current usage of toolExists relies on internal strings, the pattern itself is unsafe. If any user-controlled input or dynamically generated path containing shell metacharacters were passed to this function in the future, it would allow arbitrary command execution on the host machine.
πŸ”§ Fix: Replaced the vulnerable shell(...) wrapper with a secure direct invocation of /usr/bin/which using Foundation.Process. The tool string is now passed safely through the process.arguments array, neutralizing the injection risk entirely. Additionally, implemented FileHandle.nullDevice for standard streams to prevent unnecessary pipe allocations.
βœ… Verification: Tested locally. The function still correctly identifies if a tool exists on the system while safely handling inputs containing spaces or metacharacters.


PR created automatically by Jules for task 17173991696500172285 started by @acebytes

Replaced the vulnerable string-interpolated shell wrapper execution (`shell("/usr/bin/which \(tool)")`) with a secure, direct invocation of the `/usr/bin/which` binary using `Foundation.Process`, passing the `tool` variable strictly via the `arguments` array. Assigned `FileHandle.nullDevice` to output pipes to avoid unnecessary allocations.

Co-authored-by: acebytes <2820910+acebytes@users.noreply.github.com>
@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.

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