Skip to content

fix(security): 2 improvements across 2 files#1691

Open
tomaioo wants to merge 2 commits into
radixark:mainfrom
tomaioo:fix/security/command-injection-via-shell-true-in-exec
Open

fix(security): 2 improvements across 2 files#1691
tomaioo wants to merge 2 commits into
radixark:mainfrom
tomaioo:fix/security/command-injection-via-shell-true-in-exec

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 16, 2026

Copy link
Copy Markdown

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: High | File: .claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py:L14

The exec_command function uses subprocess.run with shell=True and passes the command string directly. If any part of the command string is derived from user input or external data (e.g., commit messages, file paths, branch names), it can lead to arbitrary command execution.

Solution

Avoid using shell=True. Pass the command as a list of arguments using shlex.split() or use shlex.quote() for individual arguments if a shell is strictly necessary.

Changes

  • .claude/skills/mechanical-refactor-verify/mechanical_refactor_verify_utils.py (modified)
  • miles/backends/training_utils/ci_utils.py (modified)

tomaioo added 2 commits July 15, 2026 17:08
- Security: Command Injection via shell=True in exec_command
- Security: Insecure Loading of PyTorch Checkpoints

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Command Injection via shell=True in exec_command
- Security: Insecure Loading of PyTorch Checkpoints

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors exec_command in mechanical_refactor_verify_utils.py to accept a list of command arguments and execute subprocesses with shell=False for improved security. Additionally, it updates torch.load in ci_utils.py to use weights_only=True. The review feedback points out a potential issue where running git diff with check=False could silently ignore errors (such as an invalid target commit) and falsely report a successful verification; it is recommended to remove check=False or set it to True to ensure failures are caught.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

print(f"[4/4] Diffing against {target_commit[:8]}...")
diff = exec_command(
f"git diff {target_commit} -- .",
["git", "diff", target_commit, "--", "."],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

By default, git diff exits with 0 on success (regardless of whether differences exist or not) and only returns a non-zero exit code on actual errors (such as an invalid target_commit).

Using check=False here is dangerous because if git diff fails (e.g., due to a bad revision or repository error), the error is silently ignored, exec_command returns an empty string, and the script incorrectly reports a successful verification (PASS: transform reproduces the commit exactly.).

Please remove check=False (or set check=True) so that any actual git errors are caught and cause the script to fail loudly.

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