spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 - t4mo

admin 2021年12月31日14:53:11评论156 views字数 1162阅读3分52秒阅读模式

前言

日常搬砖过程中在github发现的一个CVE,https://github.com/ARPSyndicate/kenzer-templates/blob/1f1dd550ddbde72cbe378452973b93b3e62003f5/jaeles/cvescan/medium/CVE-2021-21234.yam 看着带了springboot就分析了下

环境搭建

git clone https://github.com/cristianeph/vulnerability-actuator-log-viewer
启动之后访问 http://localhost:8887/manage/log/

漏洞复现分析

spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 -  t4mo
根据springboot启动日志发现/log/view 对应的方法为eu.hinsch.spring.boot.actuator.logview.LogViewEndpoint.view
spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 -  t4mo
对应代码

@RequestMapping("/view")
        public void view(@RequestParam String filename,
                         @RequestParam(required = false) String base,
                         @RequestParam(required = false) Integer tailLines,
                         HttpServletResponse response) throws IOException {
            securityCheck(filename); 
            response.setContentType(MediaType.TEXT_PLAIN_VALUE);

            Path path = loggingPath(base);
            FileProvider fileProvider = getFileProvider(path);
            if (tailLines != null) {
                fileProvider.tailContent(path, filename, response.getOutputStream(), tailLines);
            }
            else {
                fileProvider.streamContent(path, filename, response.getOutputStream());
            }
        }

先从RequestParam获取filename参数,然后调用securityCheck进行检查,判断filename是否包含..

安全检查通过之后,将application.properties中logging.path和base拼接,返回path,base从RequestParam获取,并未经过securityCheck

spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 -  t4mo
然后生成fileProvider 在调用 streamContent

spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 -  t4mo
将path和base拼接,然后用fileinputstream打开,造成任意文件读取

BY:先知论坛

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月31日14:53:11
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   spring-boot-actuator-logview 文件包含(CVE-2021-21234)漏洞分析 - t4mohttp://cn-sec.com/archives/710019.html

发表评论

匿名网友 填写信息