Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
cakephp-trusted-proxies — CakePHP 5.4.2 - 高危 - 远程 - 代理 - trustedProxies 信任来自任意 REMOTE_ADDR 的 X-Forwarded-* | Kitploit
工具/GitHubGitHub/abraxas/cakephp-trusted-proxies
漏洞分析漏洞利用Web应用程序漏洞利用安全虚拟化Web安全渗透测试
GitHubabraxas/cakephp-trusted-proxies

cakephp-trusted-proxies

CakePHP 5.4.2 - 高危 - 远程 - 代理 - trustedProxies 信任来自任意 REMOTE_ADDR 的 X-Forwarded-*

查看仓库
12天前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Abraxas Labs - cakephp-trusted-proxies

abraxaslabs.tech  ·  github.com/abraxas  ·  @abraxas_null  ·  [email protected]  ·  cakephp-trusted-proxies

cakephp-trusted-proxies

类别: HTTPS 重定向绕过 / IP-主机欺骗 可达性: 远程

CakePHP 5.4.2 (887b641) - Cake Software Foundation

HttpsEnforcerMiddleware 配置为 trustedProxies => ['10.0.0.1'] 时会调用 setTrustedProxies,该函数将 trustProxy = true 置位,且从不将列表与 REMOTE_ADDR 进行比较。此后,scheme()、host() 和 clientIp() 会采信攻击者提供的 X-Forwarded-Proto / X-Forwarded-For / X-Forwarded-Host / X-Real-IP。

默认中间件的 trustedProxies 为 null,不会启用此行为。 文档中所述的负载均衡器配置才是暴露的场景。一个未认证的 HTTP 客户端,即使并非所列出的代理,也能跳过 HTTPS 重定向并伪造客户端 IP 和 Host。

ID暂无 CVE
类别HTTPS 重定向绕过 / IP-主机欺骗
可达性远程(未认证 HTTP;应用设置了 trustedProxies)
CWECWE-441、CWE-346
CVSS高危:7.5 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N
产品CakePHP
受影响版本5.4.2 (887b641de9f7aba06071f98f17edcbc573cbcf63)
认证无。应用设置了 HttpsEnforcerMiddleware 的 trustedProxies
许可证GNU Affero GPL v3.0
实验环境仅限 127.0.0.1

攻击者能做什么

需要一个启用了 trustedProxies 的应用(典型的反向代理 HTTPS 强制场景)。无需从所列出的代理 IP 发起连接。

权限方法 / 汇聚点实验验证或推断
跳过 HTTPS 重定向 / HSTS 路径使用 X-Forwarded-Proto: https 发起 GET / HTTP 请求实验验证。返回 200,scheme=https,JSON 中有见证信息
伪造 clientIp()X-Forwarded-For: 203.0.113.50实验验证。client_ip=203.0.113.50
伪造 host()X-Forwarded-Host: spoof.invalid实验验证。host=spoof.invalid
通过 X-Real-IP 伪造X-Real-IP: 198.51.100.9实验验证。client_ip=198.51.100.9
绕过基于 clientIp() 的 IP ACL / 速率限制同样的伪造推断。RateLimitMiddleware 默认的 remote_addr 并非此漏洞
阴性对照在 /control(无 trustedProxies)上使用相同的转发头实验验证。仍然 301 重定向到 https

已排除的遗留问题:默认 trustedProxies => null;REMOTE_ADDR 本身在实验环境中仍是 Docker 网桥 IP(192.168.208.1,而非所列出的 10.0.0.1)。不是 RCE。不是 cookie-jar 漏洞。

我是如何发现的

我固定了 cakephp/cakephp 5.4.2。ServerRequest::setTrustedProxies():

public function setTrustedProxies(array $proxies): void
{
    $this->trustedProxies = $proxies;
    $this->trustProxy = true;
    $this->uri = $this->uri->withScheme($this->scheme());
}

HttpsEnforcerMiddleware 只要 trustedProxies 非 null 就会调用它。所列出的 IP 随后被用作 XFF 链上的 array_diff,而非作为对连接对端的检查。

已记录的误入歧途:将默认中间件视为该遗留问题(并非如此);将 RateLimitMiddleware 的 x-forwarded-for 称为同一漏洞(5.4.1 bakery 已将该默认值改为 remote_addr);声称 REMOTE_ADDR 本身被伪造。作秀:反弹 shell。

实验环境

python3 cakephp-trusted-proxies-Abraxas-Labs.py

或

cd lab
./run.sh

在 PHP 8.3 中使用 Composer 安装 cakephp/cakephp 5.4.2。微型应用:/ 使用 trustedProxies => ['10.0.0.1'];/control 不使用。回环 HTTP 位于 127.0.0.1:19430。

  1. GET / 无转发头 -> 301 https。
  2. GET /control 带 proto/for/host/real-ip -> 301 https。
  3. GET / 带 X-Forwarded-Proto: https -> 200,scheme https,trust_proxy=true,REMOTE_ADDR 不是 10.0.0.1。
  4. GET / 带 XFF + Host -> client_ip=203.0.113.50,host=spoof.invalid。
  5. GET / 带 X-Real-IP -> client_ip=198.51.100.9。
SUCCESS cakephp-trusted-proxies pin=5.4.2 how=app remote-addr=192.168.208.1 listed-proxy=10.0.0.1 proto-bypass=200 control-redirect=301 client-ip=203.0.113.50 host=spoof.invalid x-real-ip=198.51.100.9 CAKEPHP-TRUSTED-PROXIES-WITNESS

修复方案

仅当 REMOTE_ADDR 在受信任代理列表中时才采信转发头(Symfony 的 isFromTrustedProxy())。空列表不得启用信任。

参考资料

  • github.com/cakephp/cakephp 标签 5.4.2 (887b641de9f7aba06071f98f17edcbc573cbcf63)
  • src/Http/ServerRequest.php · src/Http/Middleware/HttpsEnforcerMiddleware.php
  • CWE-441 · CWE-346

许可证

GNU Affero GPL v3.0。参见 LICENSE。仅限回环实验环境。无担保。

下载工具