CVE-2026-59414 — Spring Boot (4.1.2.1) — CWE-22
Request matchers created by EndpointRequest and PathRequest may not correctly handle paths with trailing slashes. This may prevent security matching rules from having the intended effect and leave a path unintentionally unsecured.
Request matchers created by EndpointRequest and PathRequest may not correctly handle paths with trailing slashes. This may prevent security matching rules from having the intended effect and leave a path unintentionally unsecured.
🎯 What is this vulnerability?
This vulnerability is a Security Bypass caused by an inconsistency in path normalization between Spring Security’s request matching logic and the underlying servlet container (or Spring MVC routing).
Technical Flaw:
In Spring Boot 4.1.2.1, EndpointRequest and PathRequest matchers (used in SecurityFilterChain configurations to define which URLs require authentication or specific roles) fail to correctly normalize paths with trailing slashes (/).
1. The Mismatch: When a security rule is defined (e.g., http.authorizeHttpRequests(auth -> auth.requestMatchers("/admin/").hasRole("ADMIN"))), the matcher expects a specific path format. However, if an attacker requests /admin/ (with a trailing slash) or /admin// (double slash), the matcher may fail to recognize this as matching the /admin/ pattern.
2. The Bypass: Because the matcher returns false (no match), the security filter chain does not apply the intended authorization check (e.g., hasRole("ADMIN")). Instead, the request falls through to a default rule (often permitAll() or a less restrictive rule), allowing unauthenticated access to protected resources.
3. Root Cause: This is a classic Path Traversal/Normalization Bypass (CWE-22/CWE-73). The security layer and the application layer disagree on what the "canonical" path is. The security layer sees /admin/ as distinct from /admin, while the application layer (Spring MVC) treats them as equivalent.
CVSS Vector Analysis:
- AV:N/AC:L/PR:N/UI:N: Exploitable remotely over the network with low complexity, no privileges, and no user interaction.
- C:H/I:H/A:N: High Confidentiality and Integrity impact. An attacker can read sensitive data (C:H) and modify resources (I:H) without authentication. Availability is not directly impacted (A:N) because the service remains up, but data integrity is compromised.
- Response Headers:
X-Application-ContextorServerheaders. - Error Pages: Spring Boot’s default error page (
/error) often reveals the version in thetraceormessagefield ifserver.error.include-stacktraceis set toalwaysoron_param_trace. - Dependency Scanning: Using tools like
nmapwithhttp-enumorwhatwebto fingerprint the framework.
⚡ Attack Chain
1. Discovery & Reconnaissance
The attacker identifies that the target is running Spring Boot 4.1.2.1. This can be determined via:2. Exploitation
The attacker targets a protected endpoint, such as/api/admin/users, which is secured by a rule like:http.authorizeHttpRequests(auth -> auth
.requestMatchers("/api/admin/**").hasRole("ADMIN")
.anyRequest().permitAll()
);The Bypass:
The attacker sends a request to the same resource but appends a trailing slash: /api/admin/users/.
PoC (Illustrative):
# Normal request (Blocked by Security Filter)
curl -v http://target.com/api/admin/users
# Expected: 401 Unauthorized or 403 Forbidden
# Bypassed request (Allowed by Security Filter due to matcher failure)
curl -v http://target.com/api/admin/users/
# Expected: 200 OK (Unauthenticated access)Why it works:
1. The PathRequest matcher for /api/admin/** does not match /api/admin/users/ due to the trailing slash handling bug.
2. The request falls through to .anyRequest().permitAll().
3. Spring MVC’s DispatcherServlet normalizes /api/admin/users/ to /api/admin/users and routes it to the correct controller.
4. The controller executes, returning sensitive data to the unauthenticated attacker.
Variations to Test:
/api/admin/users// (Double slash)/api/admin/users/. (Dot suffix)/api/admin/users/%2F (URL-encoded slash)3. Post-Exploitation
/ to any protected path.POST /api/admin/roles), the attacker can modify user roles, create admin accounts, or alter application state without authentication.🌍 Real World Impact
/api/v1/users, /api/v1/orders, /actuator/env). This can lead to data breaches, exposure of API keys, and PII leakage.Practical Consequences:
🛡️ Remediation & Mitigation
1. Upgrade (Primary Fix)
EndpointRequest and PathRequest matchers correctly normalize trailing slashes to match the behavior of Spring MVC’s DispatcherServlet.2. Workarounds (If Immediate Upgrade is Not Possible)
A. Normalize Paths in a Filter (Java Code)
Add aOncePerRequestFilter before the Spring Security filter chain to normalize the request URI. This ensures that the security matcher sees the same path as the MVC layer.@Component
@Order(Ordered.HIGHEST_PRECEDENCE) // Must run before Spring Security
public class PathNormalizationFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
String uri = request.getRequestURI();
// Remove trailing slashes (except for root "/")
if (uri.length() > 1 && uri.endsWith("/")) {
uri = uri.substring(0, uri.length() - 1);
}
// Also handle double slashes
while (uri.contains("//")) {
uri = uri.replace("//", "/");
}
// Wrap request to return normalized URI
HttpServletRequestWrapper wrappedRequest = new HttpServletRequestWrapper(request) {
@Override
public String getRequestURI() {
return uri;
}
@Override
public String getServletPath() {
return uri;
}
};
filterChain.doFilter(wrappedRequest, response);
}
}B. WAF Rule (ModSecurity)
Block requests with trailing slashes on protected paths. This is a temporary mitigation and may break legitimate clients if they rely on trailing slashes.# ModSecurity Rule: Block trailing slashes on sensitive paths
SecRule REQUEST_URI "@pm /api/admin/ /api/users/ /actuator/" \
"id:100001,phase:1,deny,status:403,msg:'Trailing slash bypass attempt',log"C. Access Restrictions
If the application is internal, restrict access to the affected endpoints via network policies (firewall rules) to only trusted IPs.3. Detection (IoCs)
Web Server Logs (Nginx/Apache):
Look for requests to protected paths with trailing slashes that return 200 OK instead of 401/403.
# Example Nginx log pattern
grep "GET /api/admin/users/ HTTP/1.1" access.log | grep " 200 "Spring Boot Actuator (if exposed):
Check /actuator/httptrace for recent requests with trailing slashes.
SIEM Query (Splunk):
index=web_logs status=200 (uri="/api/admin/*/" OR uri="/api/users/*/" OR uri="/actuator/*/")⚠️ Urgency
SecurityFilterChain configurations for reliance on PathRequest or EndpointRequest matchers.
3. Monitor Logs: Check for any unauthorized access to protected endpoints with trailing slashes in the past 30 days.
4. Apply Workaround: If patching is delayed, deploy the PathNormalizationFilter or WAF rule immediately.Note: This vulnerability is a critical security bypass that can expose entire sections of an application to unauthenticated users. It should be treated as a P0 (Critical) incident.
[🤖 CVE Professor AI Security Engine]
FOFA Query