subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
warnings.append(proc.stderr.strip()) # Draw proc = subprocess.run( [sys.executable, os.path.join(script_dir, 'rdkit_mol.py'), '--smiles', canonical_smiles, '--action', 'draw', '--output', png_path], cwd=script_dir, capture_output=True, text=True, timeout=30)- Confidence
- 83% confidence
- Finding
- The code writes a PNG to a path derived from user-controlled name with only slash replacement and truncation. Because values like '..' are not neutralized, an attacker can supply a name such as '..' and cause the output path to resolve outside the intended viz directory, enabling unintended file overwrite in the parent directory when the draw helper writes the file.
