Spring Cloud Config Server 恣意文件读取误差清静通告

宣布时间 2019-04-18

误差编号和级别


CVE编号:CVE-2019-3799,危险级别:高危,CVSS分值:官方未评定


影响版本


Spring Cloud Config 2.1.0 to 2.1.1

Spring Cloud Config 2.0.0 to 2.0.3

Spring Cloud Config 1.4.0 to 1.4.5

其他不受支持的老版本 (如Spring Cloud Config1.3及其以下版本)

值得注重的是通过maven自动构建的应用,若是不指定spring-cloud-config-server的版本,默认装置的照旧spring-cloud-config-server 1.3.0不清静版本


误差概述


Spring Cloud Config一套开源漫衍式系统设置服务,为漫衍式情形提供外部设置服务支持。Spring Cloud Config Server 路径穿越与恣意文件读取误差,可通过结构的恶意请求直接读取服务器恣意文件,危害较大。


误差验证


情形搭建: https://github.com/spring-cloud/spring-cloud-config#quick-start

GET /foo/default/master/..%252F..%252F..%252F..%252Fetc%252fpasswd HTTP/1.1

Host: localhost:8888


尊龙凯时 - 人生就是搏!



Spring Cloud Config项目是一个解决漫衍式系统的设置管理计划。它包括了Client和Server两个部分,server提供设置文件的存储、以接口的形式将设置文件的内容提供出去,client通过接口获取数据、并依据此数据初始化自己的应用。Spring cloud使用git或svn存放设置文件,默认情形下使用git。


情形搭建:


Pom.xml 设置依赖


尊龙凯时 - 人生就是搏!


Application.yml 设置设置文件存放的远程客栈地址


尊龙凯时 - 人生就是搏!


启动文件


尊龙凯时 - 人生就是搏!


org/springframework/cloud/config/sever/resource/ResourceController.java中可以审查http请求名堂为@RequestMapping("/{name}/{profile}/{label}/**")

name为应客栈名称

profile为应设置文件情形

label 为git分支名

** 为详细文件名

现实测试中只需要label为保存的分支名即可,一样平常git客栈都保存master分支

以是通用poc地址为:

/test/dev/master/..%252F..%252F..%252F..%252F..%252F..%252F..%252Fetc%252Fpasswd


尊龙凯时 - 人生就是搏!


传入参数后 会挪用this.resourceRepository.findOne(name, profile, label, path)并凭证设置文件中的客栈地址去组装新的地址并获取文件内容。我们跟入到org.springframework.cloud.config.server.resource的findOne要领中。


findOne 中location为远程git地址下载到外地的tmp目录地址,然后和我们传入的path拼装为file:/var/folders/2t/2pcjgph96ms9jltyfnm5brr40000gn/T/config-repo-1763575875528585941/..%2F..%2F..%2F..%2F..%2F..%2F.-dev.%2Fetc%2Fpasswd。


this.resourceLoader.getResource(path)要领为 spring.core中封装的获取资源文件要领,默认会还原URLdecode的地址并通过 ../../将前面的tmp路径地址吃掉,最终抵达穿越到恣意路径,读取恣意文件的效果。


修复建议


Spring Cloud Config 2.1.x 升级至 to 2.1.2,Spring Cloud Config 2.0.x u升级至 2.0.4,Spring Cloud Config 1.4.x 升级至 1.4.6老版本升级到指定的清静版本spring-cloud-config-server应安排在内网中并使用Spring Security举行用户身份判断。


Spring Security设置支官方文档Securing Spring Cloud Config Server

https://github.com/spring-cloud/spring-cloud-config/commit/3632fc6f64e567286c42c5a2f1b8142bfde505c2


参考链接


https://pivotal.io/security/cve-2019-3799