Spring Boot H2 database RCE

By
Manieendar Mohan
Published on
16 Jun 2021
2 min read
Vulnerability

In modern application development, efficient database connectivity is crucial, and HikariCP has emerged as a top-tier JDBC connection pool.

In Spring Boot applications, HikariCP’s connectionTestQuery configuration (mapped to the environment variable spring.datasource.hikari.connection-test-query) plays a vital role in ensuring robust database communication.

Every time a new database connection is created, this test query is executed to verify that the connection is still alive before it’s handed over to your application. This proactive validation process is particularly triggered when you restart your application via a POST request to /actuator/restart or when changes to the database connection settings are detected through multiple incoming requests.

The H2 database console in Spring Boot is a handy tool for developers—but if misconfigured, it can open the door to remote code execution (RCE) attacks.

What are the impacts of Spring Boot H2 database RCE?

When misconfigured, the Spring Boot H2 database can lead to several Remote Code Execution (RCE).

1. Performance overhead

Executing a test query for every new connection adds additional load and latency, especially in high-traffic environments.

2. Increased database load

Frequent execution of validation queries can contribute to higher resource usage on the database, potentially affecting overall performance.

3. Misconfigured queries

If the test query is not optimized or is too complex, it may slow down connection initialization and impact application responsiveness.

4. False positives/negatives

In some scenarios, the test query might incorrectly validate a connection that is about to fail under actual load, leading to unexpected runtime issues.

5. Overhead in dynamic environments

When using features like /actuator/restart or frequent connection reinitialization, the cumulative effect of running the test query multiple times can degrade performance.

How can you mitigate Spring Boot H2 database RCE

To secure your vulnerable instance, the primary mitigation is to install the official patch provided by the vendor. This patch is designed to address the identified security vulnerability and restore the integrity of your system. Here is the process:

1. Identify affected instances

  • Conduct an audit of your environment to determine which instances are vulnerable.

  • Refer to vendor documentation to confirm the list of supported versions that require the patch.

2. Obtain the official patch

  • Download the patch directly from the official vendor website or repository.

  • Verify the integrity of the patch using the provided checksums or digital signatures.

3. Review release notes & documentation

  • Carefully read the release notes accompanying the patch to understand the changes and any potential impacts.

  • Familiarize yourself with any prerequisites or recommended configurations detailed in the documentation.


Written by
Manieendar Mohan
Manieendar Mohan
Cyber Security Lead Engineer
Experience the Beagle Security platform
Unlock one full penetration test and all Advanced plan features free for 10 days