OS command injection, simple case
Last updated
Was this helpful?
Last updated
Was this helpful?
This lab contains an OS command injection vulnerability in the product stock checker.
The application executes a shell command containing user-supplied product and store IDs, and returns the raw output from the command in its response.
To solve the lab, execute the whoami
command to determine the name of the current user.
The first step is to identify how the application processes the input parameters. Using Burp Suite, intercept the request sent when checking the stock of a product. Here's the intercepted request:
The request contains two parameters:
productId
storeId
The response returns a numeric value in plain text. At this point, we suspect the parameters are being used as part of a system command. Let’s test for command injection by sending the request to Burp Suite’s Repeater tool.
To confirm command injection, try appending a test command (like ;id
) to each parameter. Test both productId
and storeId
to determine:
Whether they are vulnerable to injection.
The order in which the parameters are executed.
Both parameters (productId
and storeId
) are injectable.
The commands are executed in sequence: productId
first, followed by storeId
.
Now that we know the parameters are injectable, we can craft a payload to execute the whoami
command and identify the current user. Append the ;whoami
command to the storeId
parameter: