Log4Shell-Like Vulnerability Found in Popular H2 Database

A critical, unauthenticated remote code execution vulnerability has been impacting the H2 database console since 2008.

An open-source Java SQL database, H2 is an in-memory solution that eliminates the need to store data on disk, and is one of the most popular Maven packages, having roughly 7,000 artifact dependencies,

Tracked as CVE-2021-42392, the newly disclosed vulnerability has been lurking in H2 since version 1.1.100, which was released in 2008. All versions through 2.0.204 (released in December 2021) are affected.

The new bug, JFrog says, has the same root cause as the famous Log4Shell bug – they both involve the Java Naming and Directory Interface (JNDI) lookup feature – yet its impact isn’t as widespread, mainly because the console isn’t always used with the H2 database and because the H2 console listens to localhost by default.

However, the severity of the issue becomes critical when the H2 console is exposed to the LAN or WAN, given that it could be exploited to execute code remotely, without authentication.

“H2 Console doesn’t accept remote connections by default. If remote access was enabled explicitly and some protection method (such as security constraint) wasn’t set, an intruder can load own custom class and execute its code in a process with H2 Console (H2 Server process or a web server with H2 Console servlet),” the H2 maintainers explain.

The issue exists because unfiltered attacker-controlled URLs are passed to a lookup function, which essentially allows for the injection of Java code remotely, thus leading to RCE.

JFrog’s security researchers, who identified the vulnerability, explain that the most severe of the possible attack vectors is through the H2 console itself, mainly because one can use public search tools to locate WAN-facing vulnerable consoles.

The researchers also identified a series of SQL-based attack vectors, some requiring authentication with high privileges, such as those of an administrator. The built-in H2 shell can also be leveraged as an attack vector, though the scenario is highly unlikely, JFrog says.

The vulnerability was addressed with the release of H2 database version 2.0.206 and all those who use the H2 console are advised to upgrade to this release as soon as possible.

“Since version 2.0.206 H2 Console and linked tables explicitly forbid attempts to specify LDAP URLs for JNDI. Only local data sources can be used,” the H2 maintainers explain.

Related: ICS Vendors Respond to Log4j Vulnerabilities

Related: New Google Tool Helps Developers Visualize Dependencies of Open Source Projects

Related: GitHub Patches Security Flaws in Core Node.js Dependencies

view counter

Ionut Arghire is an international correspondent for SecurityWeek.

Previous Columns by Ionut Arghire:

Don't forget to share

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *