Skip to content

Commit 569face

Browse files
committed
Fix command injection in UtilityManager._open_resource_file on Windows
1 parent 2a47494 commit 569face

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.jules/sentinel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
## 2024-05-24 - Windows Shell Invocation Vulnerability
3+
**Vulnerability:** Invoking shell=True with subprocess on Windows to open files (e.g., `subprocess.call(['start', filename], shell=True)`) creates a command injection risk if `filename` contains unvalidated input.
4+
**Learning:** Windows platforms offer native `os.startfile()` which is immune to this specific shell injection attack vector.
5+
**Prevention:** Always prefer `os.startfile(filename)` over `subprocess.call(..., shell=True)` for opening files on Windows.

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)