A short preamble
The H2 database console passes user-supplied driver and URL values to a JNDI lookup without validation, allowing an unauthenticated attacker to trigger remote code loading. This can lead to remote code execution on servers where the console is exposed.
jfrog.com
Published on jfrog.com
Very recently, the JFrog security research team has disclosed an issue in the H2 database console which was issued a critical CVE – CVE-2021-42392. This issue has the same root cause as the infamous Log4Shell vulnerability in Apache Log4j (JNDI remote class loading).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The JdbcUtils.getConnection method accepts a driver class name and URL and, if the driver is a JNDI Context, calls lookup on the URL without restricting it to safe protocols.
Impact
An unauthenticated attacker could achieve remote code execution on servers where the H2 console is exposed to the network, though the default configuration limits the console to localhost and newer Java versions may block remote class loading.
What the attacker needed
H2 console exposed to network; attacker can reach the console
The fix
The vulnerability was fixed in H2 version 2.0.206 by limiting JNDI URLs to the local java protocol only, denying remote LDAP/RMI queries.
How it was found
- Access the H2 console login page.
- Enter a driver class that is a JNDI Context and a URL pointing to an attacker-controlled server.
- Submit the form; the server performs a JNDI lookup and loads remote code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The H2 database has a web-based management console that lets you connect to databases by specifying a driver and a URL. The console did not check these values before using them to load Java classes from a remote address, so an attacker could make the server download and run their code. This is similar to the Log4Shell bug, but it only affects servers that expose the H2 console to the network.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.