OS command injection, simple case

Lab Description

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.

Walkthrough

Step 1: Analyzing the Request

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.

Step 2: Identifying the Vulnerable Parameter

To confirm command injection, try appending a test command (like ;id) to each parameter. Test both productId and storeId to determine:

  1. Whether they are vulnerable to injection.

  2. The order in which the parameters are executed.

After testing:

  • Both parameters (productId and storeId) are injectable.

  • The commands are executed in sequence: productId first, followed by storeId.

Step 3: Exploiting the Vulnerability

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:

Last updated

Was this helpful?