For months I've been telling people the same thing: stop building shell strings, pass a list.
subprocess.run(["echo", user_text]) with the default shell=False keeps parentheses, backticks and $(...) as plain characters. That is CWE-78, and an argv list really does close it. I even shipped a small library, shellguard, that refuses shell=True and bare-string commands so nobody on my team can slip back into the old habit.
Then a reviewer asked me a fair question: "What if the user's text is a flag?"
I had a good answer in theory and no demo. So I made one.
The demo that changed my answer
I created two files in a temp directory: one literally named -l , one named normal.txt . Then I called ls with the untrusted value as its only argument:
subprocess .…