subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
src = Path(tempfile.gettempdir()) / "lo_socket_shim.c" src.write_text(_SHIM_SOURCE) subprocess.run( ["gcc", "-shared", "-fPIC", "-o", str(_SHIM_SO), str(src), "-ldl"], check=True, capture_output=True,- Confidence
- 95% confidence
- Finding
- This code compiles native C code at runtime from a world-writable temporary directory and produces a shared object that is later injected via LD_PRELOAD. An attacker able to precreate or swap the source/output files in the temp directory could potentially achieve arbitrary code execution in the context of the process using the shim.
