> For the complete documentation index, see [llms.txt](https://ganesha-hk.gitbook.io/cybersecurity-writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-ssrf-lab/lab-5.md).

# lab-5

## SSRF with Filter Bypass via Open Redirection Vulnerability

**Difficulty:** Practitioner

### Lab Description

This lab has a stock check feature which fetches data from an internal system. The stock checker has been restricted to only access the local application.

**Objective:** Find an open redirect affecting the application and use it to access the admin interface at `http://192.168.0.12:8080/admin`, then delete the user `carlos`.

### Root Cause

The application correctly restricts the initial SSRF request to local URLs, but it automatically follows HTTP redirects without validating the final destination. An open redirect within the application allows an attacker to redirect the server's request to an arbitrary internal URL, bypassing the intended SSRF restriction.

### Exploitation

1. Identify that the `stockApi` parameter can only request URLs within the local application.
2. Discover an open redirect endpoint on the application (for example, `/product/nextProduct?path=...`).
3. Supply the open redirect URL as the `stockApi` value, with the `path` parameter pointing to the internal admin interface:

   ```
   /product/nextProduct?path=http://192.168.0.12:8080/admin
   ```
4. The stock checker requests the allowed local URL, follows the redirect to the internal admin page, and returns its content.
5. Access the admin panel from the response and note the delete endpoint.
6. Modify the `path` parameter to target the delete action:

   ```
   /product/nextProduct?path=http://192.168.0.12:8080/admin/delete?username=carlos
   ```
7. Send the request — `carlos` is deleted and the lab is complete.

### Lesson Learned

* Restricting only the initial request URL is insufficient if the application automatically follows redirects.
* Always validate the final destination after every redirect in the chain — or disable redirect following entirely when it is not required.
* Fix open redirect vulnerabilities, as they can be chained with SSRF to bypass security controls that would otherwise be effective.
* Apply allowlist validation to every request in the redirect chain, not just the first one.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ganesha-hk.gitbook.io/cybersecurity-writeups/port-swigger-ssrf-lab/lab-5.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
