> For the complete documentation index, see [llms.txt](https://kruknight.gitbook.io/daemon-of-hacking/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kruknight.gitbook.io/daemon-of-hacking/writeups/portswigger-labs/server-side-request-forgery-ssrf/basic-ssrf-against-the-local-server.md).

# Basic SSRF against the local server

## Lab Description

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2F2GEatTBID7cOG7WCMFuX%2Fimage.png?alt=media&amp;token=57b6023d-8599-4845-b8a8-61cb84e9eefb" alt=""><figcaption></figcaption></figure>

## Step 1: Observing the Application

Upon accessing the lab, we're presented with a simple **store page** listing several products.&#x20;

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FJ2j64Nz40bO5x5ht6SGd%2Fimage.png?alt=media&amp;token=989deee8-9ad3-4edc-97fc-92beda15c786" alt=""><figcaption></figcaption></figure>

When we select any item, we notice a **"Check Stock"** button.

Naturally, our first move is to intercept the request using **Burp Suite**.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FVRJAh26pTGMlsNLTXmBD%2Fimage.png?alt=media&amp;token=337396ac-7a90-4a7d-a7ce-88e708793563" alt=""><figcaption></figcaption></figure>

## Step 2: Analyzing the Request

Intercepting the request reveals something interesting:

We see that the application fetches stock information from a **backend service** using a full URL provided by the `stockApi` parameter. This immediately hints at a possible **SSRF**, since the server is fetching the data on our behalf using a URL we can control.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FDpR087qohaVrMKlalRsh%2Fimage.png?alt=media&amp;token=f17cd279-8d18-4ec2-a7a2-f0a56dd2436a" alt=""><figcaption></figcaption></figure>

## Step 3: Testing for SSRF

To test this, we tamper with the `stockApi` parameter and set it to a different internal address:

```
stockApi=http://localhost/admin
```

After sending the modified request, we receive a valid response containing the **admin panel interface**. This confirms that we’ve successfully triggered an SSRF, allowing us to access internal services not normally available to external users.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FazBEKtpfPK7Fr3V0EnuM%2Fimage.png?alt=media&amp;token=405b83dd-911d-4b34-94fe-1a20cefa7e69" alt=""><figcaption></figcaption></figure>

## Step 4: Exploiting the Admin Functionality

Following the lab’s objective, we aim to delete the `carlos` user. Based on the structure of the admin interface, we try the following payload:

```
stockApi=http://localhost/admin/delete?username=carlos
```

Upon submitting the request, we observe a **302 Found** status code in the response—indicating that the request was processed and redirected. This behavior confirms the action succeeded.

We revisit the lab page and are greeted with a **"Congratulations"** message, meaning the lab has been successfully completed.

<figure><img src="https://2387347627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F47EuhANOY5sIuDySBX97%2Fuploads%2FUMWPTFHmAYcgiGpUavnZ%2Fimage.png?alt=media&amp;token=86f8a04e-6032-4474-8a7b-40c0350aaa7a" alt=""><figcaption></figcaption></figure>

### Lessons Learned

This lab illustrates a basic but impactful SSRF scenario. Let’s break down the key takeaways:

* **Blind trust in user-controlled URLs** (like `stockApi`) can lead to SSRF.
* Internal services such as `localhost` should never be accessible through user input.
* Proper input validation, URL whitelisting, and the use of metadata-based protections can help prevent SSRF.
