CVE-2025-22235是一个Spring Boot安全漏洞,涉及EndpointRequest.to()方法在配置安全规则时可能生成错误的匹配器,导致未暴露的执行器端点路径(如/null/**)的安全保护失效。
当使用EndpointRequest.to("health")配置安全规则时,如果health端点未在management.endpoints.web.exposure.include中配置,Spring Boot会生成错误的路径匹配器/null/**,导致该路径下的所有请求都绕过认证检查。
management.endpoints.web.exposure.include=info (仅暴露info端点,health端点未暴露)EndpointRequest.to("health")引用未暴露的端点mvn spring-boot:run
直接访问 http://localhost:8080/null,无需登录即可访问,证明存在认证绕过漏洞。
访问其他受保护的端点如 http://localhost:8080/info,会要求登录。
.requestMatchers(EndpointRequest.to("health")).permitAll() // 漏洞触发点
.requestMatchers("/null").authenticated() // 应该受保护但被绕过
@GetMapping("/null")
public String sensitiveEndpoint() {
return "未登录看到此页面,说明存在CVE-2025-22235认证绕过漏洞!";
}
升级到以下修复版本:
EndpointRequest.to()所指的端点已启用并通过Web公开/null路径的请求漏洞的根本原因在于EndpointRequest.to()方法在处理未暴露的端点时,会生成错误的路径匹配器。当端点名称在management.endpoints.web.exposure.include中未配置时,Spring Boot会创建一个包含null的路径模式,导致安全规则失效。
本演示项目仅用于安全研究和教育目的,请勿在生产环境中使用。使用本项目的风险由使用者自行承担。