subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
"""返回 {<test_name>: 'passed'|'failed'|'error'|'skipped'}""" report_path = Path(tempfile.mktemp(suffix=".json")) try: subprocess.run( ["pytest", target, "-q", "--json-report", f"--json-report-file={report_path}"], cwd=str(workdir), capture_output=True, timeout=timeout, check=False,- Confidence
- 91% confidence
- Finding
- The code executes `pytest` on a caller-controlled target inside a caller-controlled working directory, which means arbitrary test code and project hooks can run as a subprocess. In an evaluation harness, that is effectively arbitrary code execution against untrusted repository contents; the timeout only limits runtime and does not prevent filesystem, network, or process side effects.
