Skip to content

Commit 685f68d

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: support 'management.endpoints.web.expose' property
1 parent 8decc13 commit 685f68d

File tree

5 files changed

+61
-9
lines changed

5 files changed

+61
-9
lines changed

java/ql/lib/semmle/code/java/security/SpringBootActuatorsConfigQuery.qll

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ private class ManagementSecurityEnabledProperty extends JavaProperty {
4242
predicate hasSecurityDisabled() { this.getValue() = "false" }
4343
}
4444

45-
/** The Spring Boot configuration property `management.endpoints.web.exposure.include`. */
46-
private class ManagementEndpointsIncludeProperty extends JavaProperty {
47-
ManagementEndpointsIncludeProperty() {
48-
this.getNameElement().getName() = "management.endpoints.web.exposure.include"
45+
/**
46+
* The Spring Boot configuration property `management.endpoints.web.exposure.include`
47+
* or `management.endpoints.web.expose`.
48+
*/
49+
private class ManagementEndpointsExposeProperty extends JavaProperty {
50+
ManagementEndpointsExposeProperty() {
51+
this.getNameElement().getName() = "management.endpoints.web." + ["exposure.include", "expose"]
4952
}
5053

5154
/** Gets the whitespace-trimmed value of this property. */
@@ -105,13 +108,13 @@ predicate exposesSensitiveEndpoint(
105108
)
106109
or
107110
springBootVersion.matches(["2.%", "3.%"]) and //version 2.x and 3.x
108-
exists(ManagementEndpointsIncludeProperty ip |
109-
ip.getFile() = propFile and
110-
ip = jpOption.asSome() and
111+
exists(ManagementEndpointsExposeProperty ep |
112+
ep.getFile() = propFile and
113+
ep = jpOption.asSome() and
111114
(
112-
ip.getValue() = "*" // all endpoints are exposed
115+
ep.getValue() = "*" // all endpoints are exposed
113116
or
114-
ip.getValue()
117+
ep.getValue()
115118
.matches([
116119
"%dump%", "%trace%", "%logfile%", "%shutdown%", "%startup%", "%mappings%",
117120
"%env%", "%beans%", "%sessions%"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# vulnerable configuration (spring boot 2.0.0.RC1): exposes health and info only by default, here overridden to expose everything
2+
management.endpoints.web.expose=*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>spring-boot-actuator-app</groupId>
8+
<artifactId>spring-boot-actuator-app</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.source>1.8</maven.compiler.source>
14+
<maven.compiler.target>1.8</maven.compiler.target>
15+
</properties>
16+
17+
<parent>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-parent</artifactId>
20+
<version>2.2.6.RELEASE</version>
21+
<relativePath/>
22+
</parent>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter-web</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-actuator</artifactId>
32+
</dependency> <!-- $ Alert -->
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-devtools</artifactId>
36+
</dependency>
37+
<!-- dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-security</artifactId>
40+
</dependency -->
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-test</artifactId>
44+
</dependency>
45+
</dependencies>
46+
47+
</project>

0 commit comments

Comments
 (0)