这是一个针对 CVE-2024-38819 的 Cloud Foundry 就绪 Spring Boot 演示项目,该漏洞是 Spring Framework 功能式静态资源处理中的路径遍历漏洞。
CVE-2024-38819 在 Spring Framework 中被修复,而不是直接在 Spring Boot 中。
Spring Boot 在演示中仍然很重要,因为它管理应用程序使用的 Spring Framework 依赖版本。换句话说,Spring Boot 的维护版本可以为你引入修复后的 Framework 版本,但漏洞代码路径和安全修复位于 Spring Framework 的 WebFlux/WebMvc 功能式静态资源处理中。
该应用展示了一个小型客户文档保险库 UI。公共文档通过 WebFlux.fn 的 RouterFunctions.resources(...) 使用 FileSystemResource 从 /files/** 提供,这符合 Spring 公告中的漏洞条件。启动时,应用会创建:
该秘密由应用生成,不包含真实凭据。
本实验室有意在两种模式下都将 Spring Boot 保持在 3.3.4,仅更改管理的 Spring Framework 版本:
| 模式 | Spring Boot | Spring Framework | 构建产物 |
|---|---|---|---|
| 易受攻击 | 3.3.4 | 6.1.13 | target/cve-2024-38819-vulnerable.jar |
| 已修复 | 3.3.4 | 6.1.14 | target/cve-2024-38819-patched.jar |
patched Maven profile 设置了:
<spring-framework.version>6.1.14</spring-framework.version>
没有该 profile 时,Spring Boot 3.3.4 管理 Spring Framework 6.1.13,这是演示中使用的易受攻击版本。
构建两个演示产物:
scripts/build-artifacts.sh
这将创建两个不同的可部署 jar 文件:
target/cve-2024-38819-vulnerable.jar
target/cve-2024-38819-patched.jar
mvn spring-boot:run
打开:
http://127.0.0.1:8080
运行受限证明:
python3 scripts/prove-secret-exposure.py --expect vulnerable
预期易受攻击的结果:
RESULT: vulnerable behavior confirmed. The fake secret was served from outside the public file root.
运行已修复模式:
mvn -Ppatched spring-boot:run
然后:
python3 scripts/prove-secret-exposure.py --expect patched
推送易受攻击版本:
scripts/cf-push-vulnerable.sh
这会将 target/cve-2024-38819-vulnerable.jar 部署为 patch-your-spring-vulnerable。
针对你的应用路由运行证明:
python3 scripts/prove-secret-exposure.py \
--target https://YOUR-VULNERABLE-ROUTE \
--allow-remote-demo \
--expect vulnerable
推送已修复版本:
scripts/cf-push-patched.sh
这会将 target/cve-2024-38819-patched.jar 部署为 patch-your-spring-patched。
运行相同的证明:
python3 scripts/prove-secret-exposure.py \
--target https://YOUR-PATCHED-ROUTE \
--allow-remote-demo \
--expect patched
清理:
cf delete patch-your-spring-vulnerable -f -r
cf delete patch-your-spring-patched -f -r