# hop-by-hop headers

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 想要在HackTricks中看到您的**公司广告**吗？ 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* 获取[**官方PEASS和HackTricks商品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧。

</details>

**这是一篇关于**[**https://nathandavison.com/blog/abusing-http-hop-by-hop-request-headers**](https://nathandavison.com/blog/abusing-http-hop-by-hop-request-headers)**的文章摘要**

跳跃头部是特定于单个传输级连接的头部，在HTTP/1.1中主要用于在两个节点之间（如客户端-代理或代理-代理）管理数据，并且不应转发。标准的跳跃头部包括`Keep-Alive`、`Transfer-Encoding`、`TE`、`Connection`、`Trailer`、`Upgrade`、`Proxy-Authorization`和`Proxy-Authenticate`，如[RFC 2616](https://tools.ietf.org/html/rfc2616#section-13.5.1)中定义。通过`Connection`头部，可以将其他头部指定为跳跃头部。

### 滥用跳跃头部

代理不正确处理跳跃头部可能导致安全问题。虽然预期代理会删除这些头部，但并非所有代理都会这样做，从而产生潜在的漏洞。

### 测试跳跃头部处理

可以通过观察服务器响应的变化来测试跳跃头部的处理，当特定头部被标记为跳跃头部时。工具和脚本可以自动化此过程，识别代理如何管理这些头部，并可能发现配置错误或代理行为。

滥用跳跃头部可能导致各种安全问题。以下是一些示例，演示了如何操纵这些头部进行潜在攻击：

### 使用`X-Forwarded-For`绕过安全控制

攻击者可以操纵`X-Forwarded-For`头部来绕过基于IP的访问控制。此头部通常由代理使用来跟踪客户端的原始IP地址。但是，如果代理将此头部视为跳跃头部并在没有适当验证的情况下转发它，攻击者可以伪造其IP地址。

**攻击场景：**

1. 攻击者向代理后面的Web应用程序发送HTTP请求，包括在`X-Forwarded-For`头部中放入虚假IP地址。
2. 攻击者还包括`Connection: close, X-Forwarded-For`头部，促使代理将`X-Forwarded-For`视为跳跃头部。
3. 配置不正确的代理将请求转发给Web应用程序，而不包含伪造的`X-Forwarded-For`头部。
4. Web应用程序看不到原始的`X-Forwarded-For`头部，可能将请求视为直接来自受信任代理，从而可能允许未经授权的访问。

### 通过跳跃头部注入进行缓存投毒

如果缓存服务器根据跳跃头部不正确地缓存内容，攻击者可以注入恶意头部来投毒缓存。这将向请求相同资源的用户提供不正确或恶意内容。

**攻击场景：**

1. 攻击者发送带有不应缓存的跳跃头部的请求到Web应用程序（例如`Connection: close, Cookie`）。
2. 配置不良的缓存服务器不会删除跳跃头部，并缓存特定于攻击者会话的响应。
3. 请求相同资源的未来用户接收到缓存响应，该响应是为攻击者定制的，可能导致会话劫持或敏感信息泄露。

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

* 您在**网络安全公司**工作吗？ 想要在HackTricks中看到您的**公司广告**吗？ 或者想要访问**PEASS的最新版本或下载HackTricks的PDF**吗？ 请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* 获取[**官方PEASS和HackTricks商品**](https://peass.creator-spring.com)
* **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: 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:

```
GET https://hacktricks.xsx.tw/pentesting-web/abusing-hop-by-hop-headers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
