Most command injection bugs come from the same line of code: a string that mixes a program name, some flags, and a value from a user, handed to a shell. The shell reads the whole string, and anything in it that looks like syntax is syntax.
This article shows what that looks like in Python and Node, the two-layer fix (no shell, plus validation), the argument-injection gap that "no shell" alone leaves open, and how to prove the fix with a harmless marker instead of trusting a linter. I ran every snippet below locally, on stand-in data.
Only test applications you own or are authorized to test. The "target" here is a tiny script I wrote that pretends to be a legacy stock-report tool, and the only thing I inject is an echo .
What it is
OS command injection (also called shell injection) means user input ends up in a command your server runs, and it can change what that command does. It is CWE-78 .β¦