CVE-2021-42392: Critical severity h2database H2 vulnerability
Impact H2 Console in versions since 1.1.100 (2008-10-14) to 2.0.204 (2021-12-21) inclusive allows loading of custom classes from remote servers through JNDI.
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).
It is also possible to load them by creation a linked table in these versions, but it requires ADMIN privileges and user with ADMIN privileges has full access to the Java process by design. These privileges should never be granted to untrusted users.
Patches 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.
Workarounds H2 Console should never be available to untrusted users.
-webAllowOthers is a dangerous setting that should be avoided.
H2 Console Servlet deployed on a web server can be protected with a security constraint: https://h2database.com/html/tutorial.html#usingH2ConsoleServlet If webAllowOthers is specified, you need to uncomment and edit <security-role> and <security-constraint> as necessary. See documentation of your web server for more details.
References This issue was found and privately reported to H2 team by JFrog Security's vulnerability research team with detailed information.
Other sources
A flaw was found in h2. The org.h2.util.JdbcUtils.getConnection method of the H2 database takes as parameters the class name of the driver and URL of the database. This flaw allows an attacker to use this URL to send another server’s code, causing remote code execution. This issue is exploited through various attack vectors, most notably through the H2 Console, which leads to unauthenticated remote code execution.
The org.h2.util.JdbcUtils.getConnection method of the H2 database takes as parameters the class name of the driver and URL of the database. An attacker may pass a JNDI driver name and a URL leading to a LDAP or RMI servers, causing remote code execution. This can be exploited through various attack vectors, most notably through the H2 Console which leads to unauthenticated remote code execution.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
redhat/eap7-h2databaseto a version that resolves this vulnerability.Fixed in 0:1.4.197-2.redhat_00004.1.el8ea - Upgrade
Upgrade
redhat/eap7-h2databaseto a version that resolves this vulnerability.Fixed in 0:1.4.197-2.redhat_00004.1.el7ea - Upgrade
Upgrade
redhat/rh-sso7-keycloakto a version that resolves this vulnerability.Fixed in 0:15.0.8-1.redhat_00001.1.el7 - Upgrade
Upgrade
redhat/rh-sso7-keycloakto a version that resolves this vulnerability.Fixed in 0:15.0.8-1.redhat_00001.1.el8 - Upgrade
Upgrade
redhat/rh-sso7-keycloakto a version that resolves this vulnerability.Fixed in 0:18.0.3-1.redhat_00001.1.el7 - Upgrade
Upgrade
redhat/rh-sso7-keycloakto a version that resolves this vulnerability.Fixed in 0:18.0.3-1.redhat_00001.1.el8 - Upgrade
Upgrade
redhat/rh-sso7to a version that resolves this vulnerability.Fixed in 0:1-5.el9 - Upgrade
Upgrade
redhat/rh-sso7-javapackages-toolsto a version that resolves this vulnerability.Fixed in 0:6.0.0-7.el9 - Upgrade
Upgrade
redhat/rh-sso7-keycloakto a version that resolves this vulnerability.Fixed in 0:18.0.3-1.redhat_00001.1.el9 - Upgrade
Upgrade
redhat/h2to a version that resolves this vulnerability.Fixed in 2.0.206 - Upgrade
Upgrade
debian/h2databaseto a version that resolves this vulnerability.Fixed in 2.1.214-1Fixed in 2.2.220-1Fixed in 2.5.252-2 - Upgrade
Upgrade
maven/com.h2database:h2to a version that resolves this vulnerability.Fixed in 2.0.206 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 2.0.206 - Configuration
Avoid enabling `webAllowOthers`; H2 Console does not accept remote connections by default.
H2 Console webAllowOthers = disabled - Configuration
If remote access is enabled with `webAllowOthers`, uncomment and edit the security role and security constraint to restrict access to the H2 Console.
H2 Console Servlet <security-role> and <security-constraint>
Event History
Parent advisories
This vulnerability appears in the following advisories.
Frequently Asked Questions
What is CVE-2021-42392?
CVE-2021-42392 is a vulnerability found in the h2 database that allows remote code execution.
How severe is CVE-2021-42392?
CVE-2021-42392 has a severity rating of 9.8, which is considered critical.
How can I fix CVE-2021-42392?
To fix CVE-2021-42392, you should update the h2 database to version 2.0.206 or apply the recommended patch provided by Red Hat.
Where can I find more information about CVE-2021-42392?
You can find more information about CVE-2021-42392 on the GitHub security advisory page and the Red Hat security advisory page.
What is the Common Weakness Enumeration (CWE) for CVE-2021-42392?
The Common Weakness Enumeration (CWE) for CVE-2021-42392 is CWE-502.