Heartbleed(CVE-2014-0160)复现与分析——CSP 应用安全项目
一个可复现的实验环境,用于课程 CSP – Solving Current Challenges in Application Security (波恩-莱茵-锡格应用技术大学)。我们在隔离的 Docker 环境中复现 Heartbleed 漏洞,分析其根本原因,并探索自动化检测方法。
Heartbleed 漏洞是如何由 OpenSSL 的 TLS 心跳实现中边界检查不足而产生的,如何在隔离且可重复的 环境中复现它,以及现代内存安全测试技术能在多大程度上检测出 这一类漏洞?
heartbleed-csp/
├── README.md # this file
├── docker-compose.yml # wires the lab containers on one Docker network
├── vulnerable/ # OpenSSL 1.0.1f + minimal TLS server (the bug is here)
│ └── Dockerfile
├── patched/ # OpenSSL 1.0.1g + minimal TLS server (fixed)
│ └── Dockerfile
├── attacker/ # Heartbleed test client (standard public PoC)
│ └── README.md
├── webapp/ # Secure Corp login portal (the CTF objective)
├── ctf.sh # CTF game controller (list levels, briefs, grade flags)
├── levels/ # one self-contained folder per CTF level
│ ├── README.md # progression map (4 attack + several defense levels)
│ ├── _template/ # copy this to add a level
│ └── attack-01-credentials/
├── detection/ # (planned) defense levels: AddressSanitizer + fuzzing
├── results/ # captured outputs, logs, screenshots
└── report-notes/ # notes for the written report
克隆并启动——只需一条命令。你专属的每位玩家 flag 会在首次运行时自动生成(由 secrets-init 服务完成),因此无需手动设置步骤:
docker compose up --build -d
首次构建会从源码编译 OpenSSL 1.0.1f,需要几分钟时间;
后续运行会使用缓存。然后打开 http://localhost:8090 处的门户并
开始游戏(见下文)。之后如需轮换 flag:scripts/gen-secrets.sh --force。
该实验环境以夺旗(capture-the-flag)游戏的形式组织。每个挑战都位于
levels/ 下各自的文件夹中,并由 ctf.sh 控制器驱动。不带
任何参数运行它即可查看快速入门指南:
./ctf.sh # welcome + first-time setup steps
./ctf.sh levels # list all levels, status, and your score
./ctf.sh brief attack-01 # read a level's objective + hints
./ctf.sh submit attack-01 'CTF_FLAG{...}' # grade your flag (+points)
./ctf.sh progress # your score and what to play next
已解决的关卡会在本地记住(保存在被 gitignore 忽略的 .ctf_progress 中),因此
levels 和 progress 会跟踪你在 1000 分中的当前得分。
第 1 关(attack-01):利用 Heartbleed 从存在漏洞的
TLS 服务器泄露门户的登录凭据,然后在 http://localhost:8090/portal 登录以显示
flag。完整流程以及如何添加新关卡,请参阅 levels/README.md。
然后运行测试(待补充文档),并比较存在漏洞与已修补版本的行为。
该实验环境运行在 Docker 桥接网络上,并且有意只在 http://localhost:8090 上发布 CTF 门户,以便玩家可以使用泄露的凭据登录;TLS 服务器 只能从实验网络内部访问。我们从不针对真实系统或真实数据:每个 秘密都是伪造的,并且每位玩家各不相同——仅限实验环境的凭据、每次启动时重新生成的临时 TLS 密钥,以及标记 flag——它们仅被植入服务器内存中,用于演示越界读取。
OpenSSL 安全公告、CVE-2014-0160(NVD),以及 OpenSSL 1.0.1f → 1.0.1g 的源码差异。 完整引用保留在报告中。