subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
with os.fdopen(fd, "w") as f: json.dump(doc, f) out_path = tempfile.mktemp(suffix=".json") subprocess.run( [sys.executable, os.path.join(os.path.dirname(__file__), "score.py"), path, "-o", out_path], check=True, capture_output=True,- Confidence
- 87% confidence
- Finding
- This subprocess call itself is not shell-injection prone because it uses an argument list and no shell, but it writes the scored output to a path created with tempfile.mktemp(), which is insecure due to a race condition. An attacker on the same system could pre-create or replace that path with a symlink before score.py writes to it, potentially causing unintended file overwrite or disclosure depending on the privileges of the process.
