The vulnerability, as described, occurs when EndpointRequest.to() is used for an actuator endpoint that is disabled or not exposed, leading to a matcher for null/**. The provided commit 55f67c9a522647039fd3294dee5cb83f4888160a patches the EndpointRequest.java files for both servlet and reactive stacks.
The core issue was that PathMappedEndpoints.getPath(endpointId) could return null for unexposed endpoints. This null value was then processed by the streamPaths method within the inner EndpointRequestMatcher class. Before the patch, streamPaths did not filter out these null paths.
These null paths were then used by the createDelegate methods (one in the servlet version, one in the reactive version of EndpointRequestMatcher) to construct matchers.
- In the servlet version, the
null path was passed to RequestMatcherFactory.antPath, which would then treat the null as the string "null" when creating the pattern, resulting in null/**.
- In the reactive version, the
null path was passed to getDelegateMatcher, which would then create a PathPatternParserServerWebExchangeMatcher using path + "/**", effectively becoming "null/**".
The patches address this by:
- Modifying
streamPaths to explicitly filter out null values returned by pathMappedEndpoints.getPath().
- Adding
Assert.notNull checks in RequestMatcherFactory.antPath (servlet) and getDelegateMatcher (reactive) to prevent null paths from being processed into matchers.
- Modifying the
createDelegate methods to return an EMPTY_MATCHER if no valid delegate matchers can be formed (e.g., if all specified endpoints are unexposed and their paths become null and are filtered out).
The createDelegate methods in EndpointRequest$EndpointRequestMatcher for both servlet and reactive stacks are identified as the vulnerable functions because they orchestrate the faulty logic of using these potentially null paths to create the incorrect matchers. They are the highest-level methods within the matcher object (returned by EndpointRequest.to()) where the decision to form matchers based on these paths occurs.