Skip to content

Commit 6e03d97

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: update qhelp
1 parent da37a91 commit 6e03d97

File tree

6 files changed

+44
-138
lines changed

6 files changed

+44
-138
lines changed

java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/InsecureSpringActuatorConfig.qhelp

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,36 @@
11
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
22
<qhelp>
33
<overview>
4-
<p>Spring Boot is a popular framework that facilitates the development of stand-alone applications
5-
and micro services. Spring Boot Actuator helps to expose production-ready support features against
6-
Spring Boot applications.</p>
7-
8-
<p>Endpoints of Spring Boot Actuator allow to monitor and interact with a Spring Boot application.
9-
Exposing unprotected actuator endpoints through configuration files can lead to information disclosure
10-
or even remote code execution vulnerability.</p>
11-
12-
<p>Rather than programmatically permitting endpoint requests or enforcing access control, frequently
13-
developers simply leave management endpoints publicly accessible in the application configuration file
14-
<code>application.properties</code> without enforcing access control through Spring Security.</p>
4+
<p>Spring Boot includes features called actuators that let you monitor and interact with your web
5+
application. Exposing unprotected actuator endpoints through configuration files can lead to
6+
information disclosure or even to remote code execution.</p>
157
</overview>
168

179
<recommendation>
18-
<p>Declare the Spring Boot Starter Security module in XML configuration or programmatically enforce
19-
security checks on management endpoints using Spring Security. Otherwise accessing management endpoints
20-
on a different HTTP port other than the port that the web application is listening on also helps to
21-
improve the security.</p>
10+
<p>Since actuator endpoints may contain sensitive information, carefully consider when to expose them,
11+
and secure them as you would any sensitive URL. Use Spring Security, which secures actuators by default,
12+
by configuring <code>spring-boot-starter-security</code> in your application. Alternatively, you can
13+
define a custom security configuration which only allows users with certain roles to access the endpoints.
14+
</p>
2215
</recommendation>
2316

2417
<example>
25-
<p>The following examples show both 'BAD' and 'GOOD' configurations. In the 'BAD' configuration,
26-
no security module is declared and sensitive management endpoints are exposed. In the 'GOOD' configuration,
27-
security is enforced and only endpoints requiring exposure are exposed.</p>
18+
<p>The following examples show <code>application.properties</code> configurations that expose sensitive
19+
actuator endpoints in different Spring Boot versions.</p>
20+
<sample src="application_bad.properties" />
21+
22+
<p>The below configurations ensure that sensitive actuator endpoints are not exposed.</p>
23+
<sample src="application_good.properties" />
24+
25+
<p>To use Spring Security, which secures actuators by default, add the <code>spring-boot-starter-security</code>
26+
dependency in your Maven <code>pom.xml</code> file.</p>
2827
<sample src="pom_good.xml" />
29-
<sample src="pom_bad.xml" />
30-
<sample src="application.properties" />
3128
</example>
3229

3330
<references>
3431
<li>
35-
Spring Boot documentation:
36-
<a href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html">Spring Boot Actuator: Production-ready Features</a>
37-
</li>
38-
<li>
39-
VERACODE Blog:
40-
<a href="https://www.veracode.com/blog/research/exploiting-spring-boot-actuators">Exploiting Spring Boot Actuators</a>
32+
Spring Boot Reference Documentation:
33+
<a href="https://docs.spring.io/spring-boot/reference/actuator/endpoints.html">Endpoints</a>.
4134
</li>
4235
<li>
4336
HackerOne Report:

java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/application.properties

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# vulnerable configuration (Spring Boot 1.0 - 1.4): exposes actuators by default
2+
3+
# vulnerable configuration (Spring Boot 1.5+): requires value false to expose sensitive actuators
4+
management.security.enabled=false
5+
6+
# vulnerable configuration (Spring Boot 2.x): exposes health and info only by default
7+
# here overridden to expose all endpoints
8+
management.endpoints.web.exposure.include=*
9+
10+
# vulnerable configuration (Spring Boot 3.x): exposes health only by default
11+
# here overridden to expose all endpoints
12+
management.endpoints.web.exposure.include=*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# safe configuration (Spring Boot 1.0 - 1.4): exposes actuators by default
2+
management.security.enabled=true
3+
4+
# safe configuration (Spring Boot 1.5+): requires value false to expose sensitive actuators
5+
management.security.enabled=true
6+
7+
# safe configuration (Spring Boot 2.x): exposes health and info only by default
8+
management.endpoints.web.exposure.include=health,info
9+
10+
# safe configuration (Spring Boot 3.x): exposes health only by default
11+
management.endpoints.web.exposure.include=health

java/ql/src/Security/CWE/CWE-200/InsecureSpringActuatorConfig/pom_bad.xml

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,12 @@
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.3.8.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>
1+
...
292
<dependency>
303
<groupId>org.springframework.boot</groupId>
314
<artifactId>spring-boot-starter-actuator</artifactId>
325
</dependency>
33-
<dependency>
34-
<groupId>org.springframework.boot</groupId>
35-
<artifactId>spring-boot-devtools</artifactId>
36-
</dependency>
376

387
<!-- GOOD: Enable Spring Security -->
398
<dependency>
409
<groupId>org.springframework.boot</groupId>
4110
<artifactId>spring-boot-starter-security</artifactId>
4211
</dependency>
43-
44-
<dependency>
45-
<groupId>org.springframework.boot</groupId>
46-
<artifactId>spring-boot-test</artifactId>
47-
</dependency>
48-
</dependencies>
49-
50-
</project>
12+
...

0 commit comments

Comments
 (0)