Command Injection Vulnerability

Command Injection is a vulnerability in web applications which allows an attacker to execute the OS commands whether it be windows or Linux on the host. It gives an attacker the feasibility to get a reverse shell connection and with that, the attacker can upload anything he wants. You can’t completely protect your websites from command injection vulnerability because sometimes applications need to communicate with the installed operating system and this can be done by running commands. If the attacker finds the command injection vulnerability in the web application, he can easily interact with the website through his shell using the wget command. The command injection vulnerability gives to an attacker direct access to Operating system running on the host and gives access to all your data.

Detecting the Command Injection Vulnerability

You can easily detect whether the command injection vulnerability resides in your websites by various commands among which most popular command is ping. The ping command can give you information about the specify packets being sent and the time delay. The simple example of the ping command is: –
& ping -c 10 192.0.0.9 &

Protecting Against Command Injection Vulnerability 

As here I mentioned you can completely remove commands because for communication it is necessary to execute commands on the server. But some preventions can be done so that you can secure your online presence: –

  1. Validating Inputs: By validating untrusted inputs, you can prevent it, for instance, the input can be given as a character, number or a symbol.
  2. Whitelist Validation: Whitelist validation is a method in which an application verifies the typed input and only executes the trusted commands. With it, only the predefined commands are executed and other commands will not get executed.
  3. Restrictions :

By restricting the user to insert executes commands is a good solution and can almost completely avoid your application from Command Injection Vulnerability.