JohannesLks/CVE-2026-27654
GitHub: JohannesLks/CVE-2026-27654
这是一个针对 NGINX ngx_http_dav_module 堆缓冲区溢出漏洞(CVE-2026-27654)的概念验证工具,能够导致远程拒绝服务或潜在的代码执行。
Stars: 0 | Forks: 0
# CVE-2026-27654
NGINX `ngx_http_dav_module` 通过 `size_t` 下溢导致的堆缓冲区溢出(远程 DoS / 潜在 RCE)
## 描述
`src/http/modules/ngx_http_dav_module.c` 中的 `ngx_http_dav_copy_move_handler()`
通过从 `Destination` 头部的 URI 路径组件中减去 location 前缀长度来计算目标 URI 长度。这两个值都是 `size_t`
(无符号 64 位)。当目标路径短于 location 前缀时,减法运算会回绕到 `~0`,产生一个巨大的 `memcpy` 长度,
该长度会溢出一个 7 字节的堆分配并导致 worker 进程崩溃。
向一个使用 `alias` 映射的 DAV location 发送单个精心构造的 `MOVE` 或 `COPY` 请求即可触发该溢出。
nginx master 进程会重新生成 worker 进程,但重复的请求会使服务器陷入持续的崩溃循环。
ASan 确认:在 `ngx_http_core_module.c:1949` 的 `memcpy` 处出现 `negative-size-param: (size=-7)`,
该调用来自 `ngx_http_dav_copy_move_handler`。
受影响版本:nginx 0.5.13 至 1.28.2(stable)和 1.29.0 至 1.29.6(mainline),
编译时启用了 `--with-http_dav_module` 且在 DAV location 中使用了 `alias`。已在 1.28.3 / 1.29.7 中修复(提交 ab4b5b8,PR #1210)。
## 使用方法
```
# Docker(推荐——从源代码构建存在漏洞的 nginx):
docker compose up -d --build
python3 poc.py --target 127.0.0.1:8080
# Native(从源代码构建 nginx 1.28.2,不使用 Docker):
./run.sh # non-ASan build (observes SIGSEGV crash)
./run.sh --asan # ASan build (definitive proof)
./run.sh --both # run both sequentially
# 针对现有的存在漏洞的 nginx 实例:
python3 poc.py --target
python3 poc.py --target --no-put # if trigger file already exists
python3 poc.py --target --verbose
```
## 环境要求
- 目标:编译时启用了 `--with-http_dav_module` 的 nginx,location 块使用了
`alias`(而非 `root`),且 `dav_methods` 包含 `COPY` 或 `MOVE`
- 攻击者:Python 3,`requests`(`pip install requests`)
- 如需本地构建:`gcc`、`make`、`libpcre2-dev`、`libssl-dev`、`zlib1g-dev`、`wget`
## 文件说明
| 文件 | 描述 |
|------|-------------|
| `poc.py` | Python PoC —— 发送 PUT + 精心构造的 MOVE 请求使 worker 崩溃 |
| `run.sh` | 从源码构建 nginx(ASan / 非 ASan)并运行 PoC |
| `Dockerfile` | 存在漏洞的 nginx 1.28.2 的多阶段构建 |
| `docker-compose.yml` | 一键式 Docker 环境配置 |
| `nginx.conf` | 存在漏洞的配置(`alias` + `dav_methods COPY MOVE`) |
| `proof_output.txt` | 实际验证时的 ASan 输出 |
## 参考资料
- https://nginx.org/en/security_advisories.html
- https://github.com/nginx/nginx/commit/ab4b5b8
- https://github.com/nginx/nginx/pull/1210
## 法律声明
本项目基于 GNU GPLv3 发布。
它仅用于防御性安全研究、教育和经授权的测试。未经所有者明确许可,请勿将此代码用于针对系统或服务的攻击。
未经授权的使用可能违反适用法律。作者未授予测试第三方系统的权限,且不对误用承担责任。
有关保修和责任条款,请参阅 LICENSE 文件。
标签:ASan, COPY请求, Cutter, CVE-2026-27654, Docker, Heap Buffer Overflow, HTTP协议, MOVE请求, NGINX, ngx_http_dav_module, Python POC, RCE, Remote DoS, size_t Underflow, WebDAV, Web安全, 内存安全, 堆溢出, 安全防御评估, 容器化测试, 整数下溢, 漏洞复现, 编程工具, 蓝队分析, 请求拦截, 远程代码执行, 远程拒绝服务, 逆向工具