A common way to protect Actuator in Spring Boot is a two-line rule: every Actuator endpoint needs an admin, and everything else is public. The rule is short and looks correct in code review.

CVE-2026-59414 shows how that rule can stop working without any error. If an Actuator endpoint path ends with a slash, for example env-admin/ instead of env-admin, the admin rule no longer matches that endpoint. The request falls through to “everything else is public”, and anyone can read it. In the lab below, that endpoint returns the app’s (fake) database password and the admin password to a request with no login.

This post reproduces the bug on Spring Boot 4.0.9 and shows the fix in 4.0.10. It explains why one character changes the result and how to check your own projects. It ends with three fixes, including two that work on versions with no free patch.

Code for this post: _resource/spring-boot-trailing-slash. Everything runs in Docker, so you don’t need Java or Maven installed. I tested it on Docker 27.4 with Spring Boot 4.0.9 and 4.0.10 on Java 21.

The Setup

The lab is one small app. It has a public page at /hello, two Actuator endpoints (health and env), and the common security rule:

@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    http
        .authorizeHttpRequests(auth -> auth
            .requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN")
            .anyRequest().permitAll())
        .httpBasic(Customizer.withDefaults());
    return http.build();
}

EndpointRequest.toAnyEndpoint() is Spring Boot’s helper for “every Actuator endpoint”. You don’t list paths yourself. Boot builds the request matcher from your Actuator settings, so the rule follows the endpoints when you rename or move them. The bug is in that step.

The settings give the env endpoint a custom path:

management.endpoints.web.exposure.include=health,env
management.endpoints.web.path-mapping.env=env-admin/
management.endpoint.env.show-values=ALWAYS
app.db.password=demo-not-a-real-secret

path-mapping changes an endpoint’s URL, so env is served at /actuator/env-admin instead of /actuator/env. Some teams use it to move well-known paths away from the defaults that scanners try. Note the slash at the end of env-admin/. It’s easy to type by habit, and Actuator accepts it: the endpoint still answers at /actuator/env-admin, so nothing looks wrong.

show-values=ALWAYS makes the env endpoint show real values instead of ******. The lab sets it so the leak is visible, but teams also turn it on to debug configuration and forget it. app.db.password is a fake secret, and the same file sets the admin user with spring.security.user.*.

See It Happen

Build the app on both versions, start them side by side, and send the same requests to each without logging in:

cd _resource/spring-boot-trailing-slash
./build.sh
./run.sh && ./check.sh

build.sh compiles the same code twice in a Maven container, once with Spring Boot 4.0.9 and once with 4.0.10. run.sh starts 4.0.9 on port 8091 and 4.0.10 on port 8092 and waits until both answer. check.sh calls three paths on each app without credentials and prints the HTTP status:

4.0.9 on :8091, 4.0.10 on :8092
== Spring Boot 4.0.9
GET /hello                 200
GET /actuator/health       401
GET /actuator/env-admin    200
== Spring Boot 4.0.10
GET /hello                 200
GET /actuator/health       401
GET /actuator/env-admin    401

On both versions, /hello is public and /actuator/health asks for a login (401), as intended. The difference is the last line. On 4.0.9, /actuator/env-admin answers 200 to a request with no credentials.

To see what that response contains, ask the 4.0.9 app for the endpoint and pull out the fake database password:

curl -s localhost:8091/actuator/env-admin | grep -o '"app.db.password":{[^}]*}'
"app.db.password":{"origin":"class path resource [application.properties] from demo-4.0.9.jar - 11:17","value":"demo-not-a-real-secret"}

The same response also includes spring.security.user.password, the password of the admin user that is supposed to protect Actuator. So a caller with no credentials gets the credentials. The admin rule never applied to this endpoint.

Why One Slash Changes the Result

The leak needs two things: a matcher that misses, and a fallback rule that allows whatever is missed.

First, the matcher is built from your setting, slash included. EndpointRequest turns each endpoint path into a pattern that ends in /**, meaning “this path and everything under it”. Before the fix, Boot appended /** to the path exactly as you wrote it:

path-mapping.env Pattern built by EndpointRequest Matches GET /actuator/env-admin?
env-admin /actuator/env-admin/** Yes
env-admin/ /actuator/env-admin//** No

The second pattern has a double slash, and the request path doesn’t, so the pattern never matches the endpoint.

Second, a missed rule falls through to the next rule. Spring Security checks the rules in authorizeHttpRequests from top to bottom and uses the first one that matches. When the Actuator rule misses, the request reaches .anyRequest().permitAll() and is allowed. With a different fallback, the same miss would not have exposed anything, which is the idea behind fix 3 below.

The same unauthenticated request, GET /actuator/env-admin, under two settings. With path-mapping env-admin, the pattern /actuator/env-admin/** matches, the Actuator rule hasRole("ADMIN") applies, and the answer is 401. With path-mapping env-admin/, the pattern /actuator/env-admin//** does not match, the request falls through to anyRequest().permitAll(), and the answer is 200 with the secret demo-not-a-real-secret.

The fix in 4.0.10 is small. It removes trailing slashes from the path before adding /** (the commit), and applies the same cleanup to the H2 console path that PathRequest.toH2Console() uses. It doesn’t change the fallback rule, which is still yours to choose.

Are You Affected?

An app is exposed only when all three of these are true:

  • It runs an affected Spring Boot version: 4.1.0 to 4.1.2, 4.0.0 to 4.0.9, 3.5.0 to 3.5.17, 3.0.0 to 3.4.18, or 2.7.35 and earlier (Spring advisory).
  • Its security rules use EndpointRequest or PathRequest.toH2Console().
  • A path those matchers are built from ends with a slash. In the lab that’s management.endpoints.web.path-mapping.*. The fix also covers the H2 console path (spring.h2.console.path).

The fallback rule decides how bad a hit is. With .anyRequest().permitAll(), the endpoint is public. With a deny-by-default fallback, it still asks for a login (fix 3 shows this).

I also tried a trailing slash on management.endpoints.web.base-path (/manage/). On 4.0.9 the endpoint stayed protected (401), so in this lab only the per-endpoint path-mapping triggered the bug. I didn’t test every combination, so scan for all three settings anyway.

The lab includes a scanner for these settings. Run it on the lab itself first, from the lab folder:

./find-trailing-slash.sh .
./src/main/resources/application.properties:5:management.endpoints.web.path-mapping.env=env-admin/

It finds the lab’s own trailing slash. Then point it at your projects, for example ./find-trailing-slash.sh ~/code/orders-service.

The script greps .properties, .yml, and .yaml files for path-mapping, base-path, and the H2 console path, and prints each match that ends with /, with its file and line number. If nothing matches, it prints No matching setting ends with a slash.

The scanner is a grep, so it has blind spots:

  • In nested YAML, a mapping such as path-mapping: followed by env: env-admin/ on the next line isn’t caught, and neither is the H2 path: key under spring.h2.console. Search nested YAML by hand.
  • Settings can also come from environment variables (for example MANAGEMENT_ENDPOINTS_WEB_PATHMAPPING_ENV), command-line arguments, or a config server. Check those sources too.

Three Ways to Fix It

1. Upgrade (best)

The fixed open-source versions are 4.1.3 and 4.0.10. For 3.5, 3.4, and 2.7, the fixes (3.5.18, 3.4.19, 2.7.36) are available only with Spring’s Enterprise Support. If you’re on 3.x or 2.7 without that support, apply the next two fixes now and plan the move to 4.1, the newest line.

After the upgrade, the lab’s 4.0.10 result above is the check: the mapped endpoint answers 401 without credentials, even with the slash still in the setting.

2. Remove the trailing slash (works on any version)

The bug needs the slash, so removing it closes the gap without an upgrade. run.sh passes extra arguments to both apps, and a command-line argument overrides application.properties. Start both builds again with the setting fixed:

./run.sh --management.endpoints.web.path-mapping.env=env-admin && ./check.sh
4.0.9 on :8091, 4.0.10 on :8092
== Spring Boot 4.0.9
GET /hello                 200
GET /actuator/health       401
GET /actuator/env-admin    401
== Spring Boot 4.0.10
GET /hello                 200
GET /actuator/health       401
GET /actuator/env-admin    401

4.0.9 is now protected too. This is the fastest fix when you can’t upgrade this week. The weakness is that it depends on nobody adding the slash back, which is why the scanner and the smoke test below are worth keeping after the fix.

3. Deny by default (protects you from the next one)

The leak happened because the fallback was .anyRequest().permitAll(). With that fallback, any rule that misses, for any reason, makes the request public. A deny-by-default rule set lists the public paths and requires a login for everything else:

auth.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN");
auth.requestMatchers("/hello").permitAll();
auth.anyRequest().authenticated();

This is the lab’s SecurityConfig with the deny-by-default branch selected. The --demo.fallback flag switches to it. Run it with the trailing slash still in place (only the 4.0.9 part of the output is shown):

./run.sh --demo.fallback=authenticated && ./check.sh
4.0.9 on :8091, 4.0.10 on :8092
== Spring Boot 4.0.9
GET /hello                 200
GET /actuator/health       401
GET /actuator/env-admin    401

The Actuator rule still misses on 4.0.9, but the request now falls to .authenticated() and gets a 401 instead of the secret. Note what this does and doesn’t give you. The endpoint now needs any logged-in user, not an admin. In an app with only one user that’s the same thing; in an app with many non-admin users, those users could still read it. Deny-by-default limits the damage, and the upgrade restores the admin rule.

The cost is that you must list every public path. A new public page returns 401 until someone adds a rule for it. That failure is loud and easy to find, which is the point.

For production, do all three. Upgrade to fix this bug, remove the slash so older builds are safe, and keep deny-by-default so the next matcher bug fails closed.

Test the Rule, Not Just the Code

This bug passes code review because the rule looks right. The rule is only correct if the running app enforces it, so test the running app. After every deploy, call each exposed Actuator endpoint at its real path without credentials, and fail the pipeline if any of them answers 200.

check.sh in the lab is that test in miniature. For your services, build the list from the effective configuration (including path-mapping and base-path), expect 401 or 403 from each, and leave out endpoints you make public on purpose, such as health for Kubernetes probes.

The same versions fix CVE-2026-59411. When a Servlet application that uses Actuator is deployed to Cloud Foundry, Spring Boot’s default web security is turned off. Apps with their own security configuration, like the one in this lab, aren’t affected. If you deploy to Cloud Foundry and rely on the defaults, upgrade, or define your own security configuration (advisory).

Clean Up

./stop.sh
docker volume rm sb-m2

sb-m2 is the Maven cache that build.sh uses to avoid downloading the dependencies twice.

Summary

  • EndpointRequest builds its matcher from your Actuator settings. Before the fix, a trailing slash such as env-admin/ produced /actuator/env-admin//**, which never matches, so the endpoint skipped the admin rule.
  • With .anyRequest().permitAll() as the fallback, a missed rule makes the endpoint public. In the lab, /actuator/env-admin returned the database and admin passwords with no login on 4.0.9, and 401 on 4.0.10.
  • Affected: 4.1.0–4.1.2, 4.0.0–4.0.9, 3.5.0–3.5.17, 3.0.0–3.4.18, and 2.7.35 and earlier. The free fixes are 4.1.3 and 4.0.10.
  • Upgrading fixes the matcher. Removing the slash works on any version. Deny-by-default turns the next missed rule into a 401 instead of a leak. Use all three.

As a next step, run find-trailing-slash.sh against your services, check nested YAML and environment variables by hand, and add an unauthenticated Actuator check to your deploy pipeline.

Resources