subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
import platform system = platform.system() if system == 'Windows': subprocess.run(['clip'], input=text.encode(), shell=True) elif system == 'Darwin': subprocess.run(['pbcopy'], input=text.encode()) else: # Linux- Confidence
- 95% confidence
- Finding
- This Windows clipboard write path invokes subprocess.run with shell=True, which is unnecessary and increases command execution risk. Although the command is constant and the input is passed via stdin rather than interpolated into the command string, using the shell broadens attack surface and can be abused in hostile execution environments or via shell resolution/path hijacking.
