Skip to content

fix(winrwe): prevent OS command injection via unquoted filenames in RW.exe calls - #117

Closed
prakashb72 wants to merge 2 commits into
intel:mainfrom
sys-xmlcli:ps_fix
Closed

prakashb72 wants to merge 2 commits into
intel:mainfrom
sys-xmlcli:ps_fix

Conversation

@prakashb72

Copy link
Copy Markdown
Contributor

No description provided.

@prakashb72
prakashb72 requested a balanced review from Copilot October 7, 2026 06:17
# Built-in imports
import os
import binascii
import subprocess
if log_file is not None:
arguments.append("/LogFile={}".format(self._validate_path(log_file)))
arguments.append("/Command={}; RwExit".format(command))
return subprocess.run(arguments, shell=False).returncode
@prakashb72 prakashb72 closed this Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The security boundary lacks regression tests for malicious paths and subprocess argument handling.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Replaces shell-based RW.exe execution with validated, argument-based subprocess calls to prevent command injection.

Changes:

  • Adds centralized path validation and RW.exe execution.
  • Migrates memory, reset, and I/O commands away from os.system.
File Description
src/​xmlcli/​access/​winrwe/​winrwe.py Validates paths and invokes RW.exe without a shell.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

def _validate_path(filename):
# RW.exe parses its own /Command string, so separators and quotes must not appear in a path.
filename = os.fspath(filename)
if any(character in filename for character in ';"\r\n'):
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.

4 participants