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 subprocess invocation builds a shell command with shell=True and interpolates the user-controlled keyword into cron_line without escaping. An attacker supplying shell metacharacters in --keyword could inject arbitrary commands during subscription setup, leading to code execution under the current user.
