subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
script_path = os.path.abspath(__file__) cron_line = f"0 9 * * * /usr/bin/python3 {script_path} --keyword {keyword} --no-open" try: subprocess.run( f'(crontab -l 2>/dev/null; echo "{cron_line}") | crontab -', shell=True, check=True, capture_output=True )- Confidence
- 99% confidence
- Finding
- This code builds a shell command containing user-controlled keyword data and executes it with shell=True when installing a crontab entry. A crafted keyword containing shell metacharacters or quotes could break out of the intended cron line and execute arbitrary commands on the host.
