Skip to content

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

Merged
Rootless-Ghost merged 1 commit into
masterfrom
alert-autofix-2
Apr 13, 2026
Merged

Potential fix for code scanning alert no. 2: Uncontrolled command line#9
Rootless-Ghost merged 1 commit into
masterfrom
alert-autofix-2

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

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

Best fix: stop interpolating raw user input into shell command text. Instead, escape/substitute values safely per target shell before building the final command.

In this codebase, the least disruptive fix is:

  1. Add a shell-escaping helper in core/executor.py that quotes each substituted value according to executor type (bash/sh via shlex.quote, cmd via conservative double-quote escaping, powershell via single-quote escaping).
  2. Add a new substitution function that applies this escaping during #{var} replacement.
  3. Update core/engine.py to call the new safe substitution function (for both main and cleanup commands), passing test["executor_type"].
  4. Keep existing validation as defense-in-depth.

This preserves existing functionality (still supports same templates and executors) while neutralizing command injection vectors from input_arguments.

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 13, 2026
@Rootless-Ghost Rootless-Ghost marked this pull request as ready for review April 13, 2026 15:02
@Rootless-Ghost Rootless-Ghost merged commit ce9d2bd into master Apr 13, 2026
5 of 6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-2 branch April 13, 2026 15:02
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