5

CVE-2021-21234 Spring Boot Actuator Logview Directory Traversal

 2 years ago
source link: https://y4er.com/post/cve-2021-21234-spring-boot-actuator-logview-directory-traversal/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
1 min read

CVE-2021-21234 Spring Boot Actuator Logview Directory Traversal

2021-12-01 代码审计 springboot cve java

项目地址:https://github.com/lukashinsch/spring-boot-actuator-logview

在spring-boot-actuator-logview 0.2.13版本之前,对文件路径参数过滤不严导致可以目录穿越读取任意文件。

git clone https://github.com/cristianeph/vulnerability-actuator-log-viewer

idea打开运行即可

靶场使用的版本为spring-boot-actuator-logview 0.2.12

在logview的spring.factories中存在spring的AutoConfiguration配置

image.png

当springboot初始化bean时,如果application.properties配置有logging.path属性时

image.png

返回一个LogViewEndpoint端点,该端点实现了MvcEndpoint接口,定义了以下几个路由

  1. list() -> / 列出日志文件
  2. view() -> /view 读日志文件
  3. search() -> /search 搜索日志文件

其中在view()中,存在任意文件读取。

image.png

用户可以提交filename和base参数,其中filename经过securityCheck()判断

image.png

限制了跨目录操作,但是this.loggingPath(base)并没有进行过滤

image.png

所以可以构造http://localhost:8887/manage/log/view?filename=src/main/resources/application.properties&base=../读取任意文件

image.png

image.png

用了一个this.loggingPath,值为application.properties中写的logging.path=logs,然后取要读的文件绝对路径和logs目录的绝对路径进行匹配。

image.png

如果canonicalLoggingPath.startsWith(baseCanonicalPath)不为true直接抛出异常,完美堵死。

文笔垃圾,措辞轻浮,内容浅显,操作生疏。不足之处欢迎大师傅们指点和纠正,感激不尽。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK