Skip to content

Potential fix for code scanning alert no. 13: Uncontrolled command line#16

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

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

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

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

Best fix: stop embedding target_host (and credentials) into the PowerShell script text. Instead, pass them as PowerShell arguments and reference them inside a fixed script via param(...). This keeps the executed script structure constant and treats user input as data, not code.

In core/remote_executor.py, replace the ps_script construction and command list assembly (around lines 183–197) with:

  • A constant script block using param($ComputerName, $Username, $Password).
  • New-PSSession -ComputerName $ComputerName (no string interpolation).
  • Optional credential creation only if username/password are provided.
  • Invoke-Command -Session $_s -ScriptBlock { <resolved allowlisted command> }.
  • Build cmd_list as [..., "-Command", ps_script, "-ComputerName", target_host, "-Username", username_arg, "-Password", password_arg].

This preserves functionality while removing the tainted flow into executable command text.

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:35
@Rootless-Ghost Rootless-Ghost merged commit 54e3e84 into master Apr 25, 2026
6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-13 branch April 25, 2026 20:35
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