Skip to content

Commit f3fbfed

Browse files
committed
Fix command injection vulnerability in utility_manager.py
Replaced `subprocess.call(['start', filename], shell=True)` with `os.startfile(filename)` to prevent arbitrary command execution via maliciously crafted filenames on Windows.
1 parent 2a47494 commit f3fbfed

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+
## 2024-05-31 - Safe File Opening on Windows
2+
**Vulnerability:** Command injection via `subprocess.call(['start', filename], shell=True)` when opening files on Windows.
3+
**Learning:** Using `shell=True` with list arguments can still lead to command injection on Windows because the shell evaluates metacharacters.
4+
**Prevention:** Use `os.startfile(filename)` on Windows, which natively handles file opening 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)