-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Promote Insecure Spring Boot Actuator Configuration query from experimental #20006
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
base: main
Are you sure you want to change the base?
Java: Promote Insecure Spring Boot Actuator Configuration query from experimental #20006
Conversation
QHelp previews: java/ql/src/Security/CWE/CWE-200/SpringBootActuatorsConfig/SpringBootActuatorsConfig.qhelpExposed Spring Boot actuators in configuration fileSpring Boot includes features called actuators that let you monitor and interact with your web application. Exposing unprotected actuator endpoints through configuration files 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. If you need to expose actuator endpoints, use Spring Security, which secures actuators by default, or define a custom security configuration. ExampleThe following examples show
The below configurations ensure that sensitive actuator endpoints are not exposed.
To use Spring Security, which secures actuators by default, add the ...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- GOOD: Enable Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
...
References
|
...ecurity/CWE-200/semmle/tests/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.qlref
Fixed
Show fixed
Hide fixed
d8bbc2b
to
cde1939
Compare
java/ql/lib/semmle/code/java/security/SpringBootActuatorsConfigQuery.qll
Fixed
Show fixed
Hide fixed
c0680d1
to
9ac212d
Compare
java/ql/lib/semmle/code/java/security/SpringBootActuatorsConfigQuery.qll
Fixed
Show fixed
Hide fixed
java/ql/lib/semmle/code/java/security/SpringBootActuatorsConfigQuery.qll
Fixed
Show fixed
Hide fixed
java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.ql
Fixed
Show fixed
Hide fixed
java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.ql
Fixed
Show fixed
Hide fixed
9ac212d
to
8dd8c17
Compare
java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.ql
Fixed
Show fixed
Hide fixed
8dd8c17
to
c31fb17
Compare
java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.ql
Fixed
Show fixed
Hide fixed
c31fb17
to
6a6b794
Compare
splitting is required to properly test each scenario
Need the existence of an ApplicationProperties File, not an ApplicationProperties ConfigPair
6a6b794
to
56f667d
Compare
…to align with Spring docs
56f667d
to
7250265
Compare
|
||
from SpringBootStarterActuatorDependency d, JavaPropertyOption jpOption | ||
where exposesSensitiveEndpoint(d, jpOption) | ||
select d, "Insecure Spring Boot actuator $@ exposes sensitive endpoints.", jpOption, "configuration" |
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.
I'm conflicted about whether the alert location should be on the dependency in the pom file versus on the property in the configuration file. If the developer wants to fix the issue by adding Spring Security to the classpath, then they need to edit the pom file, so in that case the alert in the pom file makes sense, but if the developer wants to instead edit the configuration in the .properties
file, then it would make more sense to have the alert there. I've left the alert location in the pom file for now with the config file as a related location, but let me know if you think I should switch them. (Note that switching them would require selecting the properties file as a whole for the 1.0-1.4 case where the necessary property does not exist).
// version 2.x: exposes health and info only by default | ||
springBootVersion.matches("2.%") and | ||
not ep.getValue() = ["health", "info"] | ||
or | ||
// version 3.x: exposes health only by default | ||
springBootVersion.matches("3.%") and | ||
not ep.getValue() = "health" |
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.
I've changed this from checking for a specific list of endpoints to checking for not health/info to align with what the Spring documentation considers to be potentially sensitive endpoints. Let me know if you think this errs too much towards FPs, and I can change it back. This change only added 7 results in MRVA.
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.
Pull Request Overview
This PR promotes the experimental query java/insecure-spring-actuator-config
to the main query pack as java/spring-boot-exposed-actuators-config
, enabling it to appear in default CodeQL results.
Key changes include:
- Adding support for Spring Boot version 3.x
- Extending configuration property detection beyond
application.properties
to any.properties
file - Refactoring from experimental CWE-016 categorization to production CWE-200
Reviewed Changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
java/ql/src/Security/CWE/CWE-200/SpringBootActuatorsConfig/SpringBootActuatorsConfig.ql | New main query implementing the promoted actuator configuration detection |
java/ql/lib/semmle/code/java/security/SpringBootActuatorsConfigQuery.qll | Core logic library for detecting insecure Spring Boot actuator configurations |
java/ql/lib/semmle/code/configfiles/ConfigFiles.qll | Added PropertiesFile class to support broader .properties file detection |
java/ql/test/query-tests/security/CWE-200/semmle/tests/SpringBootActuatorsConfig/ | Comprehensive test suite covering Spring Boot versions 1.x through 3.x |
java/ql/src/experimental/Security/CWE/CWE-016/ | Removal of experimental query files |
java/ql/integration-tests/java/query-suite/*.expected | Updated query suite expectations to include the new query |
Description
This PR promotes
java/insecure-spring-actuator-config
from experimental asjava/spring-boot-exposed-actuators-config
(original PR: #5384).Consideration
Main changes from the experimental query:
application.properties
file, I've used the pre-existingJavaProperty
class which only looks for the.properties
extension. Spring allows changing the theapplications.properties
name, so this update reduces FNs.management.endpoint.web.expose
. This property is not particularly common, but was available in at least one version 2.x, so I've added it since it was easy to add.