subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def copy_to_clipboard(text): """Copy text to clipboard using Windows clip command.""" try: proc = subprocess.Popen(['clip'], stdin=subprocess.PIPE, shell=True) proc.communicate(text.encode('utf-8')) print("[OK] Copied to clipboard!", file=sys.stderr) except Exception as e:- Confidence
- 94% confidence
- Finding
- The code invokes a subprocess with shell=True, which is unnecessary for running the fixed Windows clip utility and causes command resolution to occur through the shell. Even though no user-controlled arguments are interpolated, shell execution increases attack surface via PATH/COMSPEC hijacking or unexpected shell behavior, especially in untrusted environments.
