Skip to content

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

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

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

Conversation

@Rootless-Ghost
Copy link
Copy Markdown
Owner

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

General fix: do not accept raw executable command text from the API. Accept a stable identifier (for example command_id) and resolve it server-side to a hard-coded/embedded allowlisted command literal, then execute only that resolved literal.

Best fix here without changing core execution behavior: in app.py’s execute endpoint, ignore body["command"] for execution and require a command_id that maps to a server-side command dictionary. Keep command only for compatibility in response/logging if needed, but execution must use resolved command text from the allowlist mapping. In core/executor.py, keep existing _is_allowed_atomic_command check as defense in depth.

Concretely:

  • File: app.py, in the execute route block (around lines 242–283).
  • Add a small embedded mapping from IDs to commands (or a helper lookup if already present in shown snippet scope).
  • Replace direct assignment command = str(body.get("command", "")).strip() with:
    • read command_id,
    • resolve command = COMMANDS.get(command_id),
    • reject if missing/unknown.
  • Keep existing _is_allowed_atomic_command(command, executor_type) validation.
  • No changes required in core/executor.py for sink call once untrusted raw command input is removed at source.

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:38
@Rootless-Ghost Rootless-Ghost merged commit 824043b into master Apr 25, 2026
6 checks passed
@Rootless-Ghost Rootless-Ghost deleted the alert-autofix-8 branch April 25, 2026 20:39
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