subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
) try: subprocess.check_call(f'{editor} "{fname}"', shell=True) except FileNotFoundError as e: if not e.filename: e.filename = editor- Confidence
- 98% confidence
- Finding
- The code builds a shell command from the editor value and executes it with shell=True: subprocess.check_call(f'{editor} "{fname}"', shell=True). The editor value can come from a CLI option or from the VISUAL/EDITOR environment variables, so an attacker who can influence those inputs can inject arbitrary shell metacharacters and achieve command execution; quoting only fname does not make the overall command safe.
