> 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/host-header/authentication-bypass-via-host-header.md).

# 通过 Host 头绕过身份验证

### 主机头认证绕过

**实验说明**

这个实验基于一个错误的服务器端假设：用户权限级别是根据 HTTP 头的值来确定的 **Host**。/ 通过处理这个头，可以访问仅限管理员使用的功能。

\*\*目标：\*\*/ 进入管理面板并删除用户 **carlos**.

\*\*观察到的初始行为\*\*

当尝试使用标准请求访问管理页面时，访问被拒绝。

普通请求：

```http
GET /admin HTTP/2
Host: 0aa100b30336117186f29ede001a0029.web-security-academy.net
```

响应：未授权访问

<figure><img src="/files/40822d948e07d554b7510a2181c6e37556d07e43" alt=""><figcaption></figcaption></figure>

**漏洞分析**

当请求来自被视为“内部”或可信的主机时，应用似乎会授予高权限，例如 **localhost**。/ 不会执行额外验证来确认请求的真实来源。

```http
Host: 0aa100b30336117186f29ede001a0029.web-security-academy.net
```

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

**利用**

只需手动修改 **Host** HTTP 请求中的头部值。

修改后的请求：

```http
Host: localhost
```

结果：已获准访问管理面板

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

**最终操作**

一旦获得管理员访问权限，就可以删除目标用户：

```bash
/admin/delete?username=carlos
```

<figure><img src="/files/6e4a84c4b24ee955705eb33f70376e43c52b3e59" 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/host-header/authentication-bypass-via-host-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.
