Skip to content

Potential fix for code scanning alert no. 3: Uncontrolled command line - #1

Merged
Rootless-Ghost merged 2 commits into
masterfrom
alert-autofix-3
Apr 13, 2026
Merged

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

Conversation

@Rootless-Ghost

Copy link
Copy Markdown
Owner

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

Best fix: stop embedding user-influenced values into a PowerShell command string. Instead, pass the script via -File and pass parameters as separate process arguments so they are not re-parsed as executable code. Also validate log_sources against an allowlist of supported channel names before serialization.

Concretely in core/event_collector.py:

  • Add tempfile import.
  • In collect_events, sanitize log_sources to only permitted entries from DEFAULT_LOG_SOURCES (fallback to defaults if none valid).
  • In _query_wel, write _PS_COLLECT to a temporary .ps1 file and call:
    • powershell.exe -NonInteractive -NoProfile -File <tmp.ps1> -StartTime <...> -LogNamesJson <...> -MaxPerLog <...>
      This removes -Command string construction and prevents command injection through interpolated text.

No behavior change to successful collection logic/output.

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
Comment thread core/event_collector.py
)
try:
proc = subprocess.run(
ps_args,
… line'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Rootless-Ghost
Rootless-Ghost marked this pull request as ready for review April 13, 2026 14:32
@Rootless-Ghost
Rootless-Ghost merged commit 07a37e9 into master Apr 13, 2026
4 of 5 checks passed
@Rootless-Ghost
Rootless-Ghost deleted the alert-autofix-3 branch April 13, 2026 14:33
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