Testing for Command Injection (OTG-INPVAL-013)

Revision as of 18:50, 14 November 2006 by Mmeucci (Talk | contribs)

Jump to: navigation, search

OWASP Testing Guide v2 Table of Contents

Brief Summary

In this paragraph we describe how to test an application for OS commandind testing: this means try to inject an on command throughout an HTTP request to the application.

Short Description of the Issue

OS Commanding is a technique used via a web interface in order to execute OS commands on the web server.

The user supplies operating system commands through a web interface in order to execute OS commands. Any web interface that is not properly sanitized is subject to this exploit. With the ability to execute OS commands, the user can upload malicious programs or even obtain passwords. OS commanding is preventable when security is emphasized during the design and development of applications.

Black Box testing and example

When viewing a file in a web application the file name is often shown in the URL. Perl allows piping data from a process into an open statement. The user can simply append the Pipe symbol “|” onto the end of the filename.
Example URL before alteration:
Example URL modified:
This will execute the command “/bin/ls”.
Appending a semicolon to the end of a URL for a .PHP page followed by an operating system command, will execute the command.
http://sensitive/something.php? dir=%3Bcat%20/etc/passwd

Gray Box testing

The URL and form data needs to be sanitized for invalid characters. A “blacklist” of characters is an option but it may be difficult to think of all of the characters to validate against. Also there may be some that were not discovered as of yet. A “whitelist” containing only allowable characters should be created to validate the user input. Characters that were missed as well as undiscovered threats should be eliminated by this list.
The web application and its components should be running under strict permissions that do not allow operating system command execution.




OWASP Testing Guide v2

Here is the OWASP Testing Guide v2 Table of Contents