Menu

An argv list fixed the injection. A deadline fixed the hang.
πŸ“°

An argv list fixed the injection. A deadline fixed the hang.

DEV Community: pythonΒ·Aurum RevenueΒ·11 days ago
#i5F56d7o
#devtopython#devto#dev#shell#command
Long article (862 words) β€” no AI summary yet.
Reading 0:00
15s threshold

An argv list fixed the injection. A deadline fixed the hang.

For months the advice I gave was the same: stop building shell strings, pass a list. If a value came from a user, it stayed data. subprocess.run(["echo", text]) and the parentheses, backticks and $(...) inside text never reach a shell, because there is no shell to reach.

That part works. I shipped a small library, shellguard, that refuses shell=True and bare-string commands so nobody on my team can drift back into the old habit. It is 144 tests deep now, and the attack suite covers the usual metacharacters.

But a clean injection story still leaves one failure on the table.

A command can be perfectly safe and still never come back.

I had a wrapper around a CLI that occasionally blocked waiting on input nobody was going to give it. The argv list was fine. No shell involved. The process just sat there, holding a worker slot, until something upstream gave up and killed the whole job. At the time I treated it as an infrastructure problem.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.