Skip to content

🔒 Fix command injection vulnerability in file verification template - #9

Open
Wenbobobo wants to merge 1 commit into
mainfrom
fix-verify-changed-file-command-injection-6585239734068860722
Open

🔒 Fix command injection vulnerability in file verification template#9
Wenbobobo wants to merge 1 commit into
mainfrom
fix-verify-changed-file-command-injection-6585239734068860722

Conversation

@Wenbobobo

Copy link
Copy Markdown
Owner

🎯 What: The _verify_changed_file function previously executed a configurable verification template string through bash -lc, which allowed for arbitrary command injection if an attacker could control or manipulate the template or file path.
⚠️ Risk: A malicious actor could inject harmful shell commands via the file path or an overridden ARCHON_SUPERVISOR_VERIFY_TEMPLATE environment variable, leading to unauthorized code execution and complete compromise of the runtime environment.
🛡️ Solution: Switched from executing the command via bash -lc to splitting the template string securely using shlex.split, safely substituting the {file} variable into the resulting argument list, and invoking it directly with subprocess.run (without shell interpretation). Also gracefully handles malformed template strings.


PR created automatically by Jules for task 6585239734068860722 started by @Wenbobobo

Copilot AI review requested due to automatic review settings July 11, 2026 09:56
@google-labs-jules

Copy link
Copy Markdown

👋 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Hardens the supervisor’s “changed file verification” step by removing bash -lc execution and instead invoking the verification command via an argument vector, reducing the risk of shell-based command injection via the {file} substitution.

Changes:

  • Parse the verification template with shlex.split() and run it via subprocess.run(rendered_args) (no shell).
  • Replace {file} placeholders in the parsed argv list with the actual path.
  • Return a structured failure when the template cannot be parsed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1513 to 1516
rendered_args = [arg.replace("{file}", str(file_path)) for arg in args]
result = subprocess.run(
["bash", "-lc", rendered],
rendered_args,
cwd=str(workspace),
Comment on lines 1507 to +1511
command = template or "timeout 30s lake env lean {file}"
rendered = command.format(file=shlex.quote(str(file_path)))
try:
args = shlex.split(command)
except ValueError as e:
return False, f"invalid verify template: {e}"
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.

2 participants