Login

Operating system command injection (timing attack)

Critical Web Application Scanning Plugin ID 98124

Synopsis

Operating system command injection (timing attack)

Description

To perform specific actions from within a web application, it is occasionally required to run Operating System commands and have the output of these commands captured by the web application and returned to the client. OS command injection occurs when user supplied input is inserted into one of these commands without proper sanitisation and is then executed by the server. Cyber-criminals will abuse this weakness to perform their own arbitrary commands on the server. This can include everything from simple `ping` commands to map the internal network, to obtaining full control of the server. By injecting OS commands that take a specific amount of time to execute, scanner was able to detect time based OS command injection. This indicates that proper input sanitisation is not occurring.

Solution

It is recommended that untrusted data is never used to form a command to be executed by the OS. To validate data, the application should ensure that the supplied value contains only the characters that are required to perform the required action. For example, where the form field expects an IP address, only numbers and periods should be accepted. Additionally, all control operators (`&`, `&&`, `|`, `||`, `$`, `\`, `#`) should be explicitly denied and never accepted as valid input by the server.