-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Promote Spring Boot Actuators query from experimental #18793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Promote Spring Boot Actuators query from experimental #18793
Conversation
QHelp previews: java/ql/src/Security/CWE/CWE-200/SpringBootActuators.qhelpExposed Spring Boot actuatorsSpring Boot includes features called actuators that let you monitor and interact with your web application. Exposing unprotected actuator endpoints can lead to information disclosure or even to remote code execution. RecommendationSince actuator endpoints may contain sensitive information, carefully consider when to expose them, and secure them as you would any sensitive URL. Actuators are secured by default when using Spring Security without a custom configuration. If you wish to define a custom security configuration, consider only allowing users with certain roles to access these endpoints. ExampleIn the first example, the custom security configuration allows unauthenticated access to all actuator endpoints. This may lead to sensitive information disclosure and should be avoided. In the second example, only users with @Configuration(proxyBeanMethods = false)
public class CustomSecurityConfiguration {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// BAD: Unauthenticated access to Spring Boot actuator endpoints is allowed
http.securityMatcher(EndpointRequest.toAnyEndpoint());
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll());
return http.build();
}
}
@Configuration(proxyBeanMethods = false)
public class CustomSecurityConfiguration {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
// GOOD: only users with ENDPOINT_ADMIN role are allowed to access the actuator endpoints
http.securityMatcher(EndpointRequest.toAnyEndpoint());
http.authorizeHttpRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN"));
return http.build();
}
} References |
…tpRequests, AuthorizeHttpRequestsConfigurer, securityMatcher(s)
9f3980e
to
c2e859c
Compare
java/ql/lib/semmle/code/java/frameworks/spring/SpringSecurity.qll
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. But if we are adding public classes to semmle.code.java.frameworks.spring
it might make sense to prefix the names with Spring
.
Thanks for the review @egregius313! I've updated the class names in 746f022 (and 82062e2). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything LGTM now.
I'll review this on behalf of Docs, probably Monday now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from a Docs perspective ✨
Added a couple of suggestions to improve readability.
java/ql/src/change-notes/2025-02-24-spring-boot-actuators-promo.md
Outdated
Show resolved
Hide resolved
Co-authored-by: mc <[email protected]>
Thanks for the review @mchammer01! I've applied your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proxying Ed's approval
This PR promotes
java/spring-boot-exposed-actuators
from experimental (original PRs: #2901 and #3506).Changes from the experimental query:
HttpSecurity.securityMatcher(s)
,HttpSecurity.authorizeHttpRequests
, andAuthorizeHttpRequestsConfigurer
, which were added in more recent Spring versions.springframework-5.3.8
stubs directory should technically be renamed tospringframework-5.8.x
. I'll do that in follow-up PR to avoid a large number of renamed stub files and updatedoptions
files on this PR.