-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: main
Are you sure you want to change the base?
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 access to the 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
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.