Concepts / Web injection and scripting

Web injection and scripting

Command injection

Also called OS command injection, shell injection

Running your own operating-system commands by sending input a web app pastes into a shell command line.

The shell reads ; as a new command
The shell reads ; as a new command

The app pastes the input into a command line, and the shell splits it at the semicolon into two commands. Passed as one argument without a shell, the same input is only an odd host name.

Command injection is running your own operating-system commands through input a web app pastes into a shell command line. If the app runs ping -c 1 <host> through a shell, ;, | and && start a second command, so 127.0.0.1; id runs ping and then id, as the server's user, often root. The fix: run the program directly with its arguments as a list, never through a shell.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab