Skip to content

Commit 04e089e

Browse files
committed
πŸ›‘οΈ Sentinel: [CRITICAL] Fix command injection in Windows file launch
🚨 Severity: CRITICAL πŸ’‘ Vulnerability: Command injection via `subprocess.call` with `shell=True` and unsanitized filename when opening files on Windows. 🎯 Impact: An attacker who can control the filename could execute arbitrary shell commands. πŸ”§ Fix: Replaced `subprocess.call` with `os.startfile(filename)` to securely open files on Windows. βœ… Verification: Run the test suite and ensure no new regressions are found.
1 parent 2a47494 commit 04e089e

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

β€Ž.jules/sentinel.mdβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 2025-02-23 - Command Injection in Windows File Launch
2+
**Vulnerability:** Using `subprocess.call(['start', filename], shell=True)` for opening files on Windows creates a command injection risk if `filename` contains shell metacharacters.
3+
**Learning:** Passing a list to `subprocess.call` with `shell=True` does not safely quote arguments on Windows, allowing execution of arbitrary commands if the file path is malicious.
4+
**Prevention:** Use `os.startfile(filename)` on Windows to open files securely without invoking the command shell.

β€Žlibs/utility_manager.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _open_resource_file(self, filename):
4343
try:
4444
if os.path.isfile(filename):
4545
if platform.system() == "Windows":
46-
subprocess.call(['start', filename], shell=True)
46+
os.startfile(filename)
4747
elif platform.system() == "Darwin":
4848
subprocess.call(['open', filename])
4949
elif platform.system() == "Linux":

0 commit comments

Comments
Β (0)