Skip to content

Potential fix for code scanning alert no. 2: Uncontrolled command line#15

Merged
Rootless-Ghost merged 1 commit intomasterfrom
alert-autofix-232
Apr 25, 2026
Merged

Potential fix for code scanning alert no. 2: Uncontrolled command line#15
Rootless-Ghost merged 1 commit intomasterfrom
alert-autofix-232

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/Rootless-Ghost/AtomicLoop/security/code-scanning/2

To fix this without changing intended functionality, keep the allowlist gate but remove avoidable shell interpretation in _build_command for bash, sh, and non-Windows cmd fallback. Instead of ["bash", "-c", command] / ["sh", "-c", command], parse command into argv with shlex.split(command) and execute directly. This prevents shell metacharacter chaining from being interpreted as new commands.

Best concrete change:

  • File: core/executor.py
  • Region: _build_command(...) (lines around 294–305 in snippet)
  • Replace shell -c launches for:
    • non-Windows cmd fallback
    • bash
    • sh
  • Use shlex.split(command, posix=(platform.system().lower() != "windows")).
  • If parsing fails (ValueError) or command is empty, return None so execute() responds with unsupported/invalid command error path.
  • Keep PowerShell/Windows cmd behavior unchanged to minimize functional impact for platform-native executors.

No changes are required in app.py for this specific sink hardening.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Rootless-Ghost Rootless-Ghost self-assigned this Apr 25, 2026
@Rootless-Ghost Rootless-Ghost marked this pull request as ready for review April 25, 2026 20:32
@Rootless-Ghost Rootless-Ghost merged commit a931976 into master Apr 25, 2026
6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-232 branch April 25, 2026 20:32
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