Skip to content

Commit f2fad81

Browse files
committed
Fix command injection vulnerability in Windows resource opener
Replaced `subprocess.call(['start', filename], shell=True)` with `os.startfile(filename)` to prevent OS command injection via user-supplied filenames on Windows.
1 parent 2a47494 commit f2fad81

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-06-08 - OS Command Injection in Windows Resource Opener
2+
**Vulnerability:** Command injection vulnerability via `subprocess.call(['start', filename], shell=True)` when handling file paths in Windows.
3+
**Learning:** Using `shell=True` with user-supplied or external inputs (even file paths) can lead to arbitrary command execution on Windows.
4+
**Prevention:** Use `os.startfile(filename)` instead of shelling out on Windows, which directly leverages the OS API without a command shell layer.

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)