CVE-2021-42392: H2 Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-h376-j262-vhq6
CVSS 9.8
CWE-502
Published
Advisory Summary

CVE-2021-42392 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting H2 libraries in the Maven ecosystem. The issue involves rce in h2 console. Remediation is available by upgrading affected packages to version 2.0.206.

CVE-2021-42392 at a Glance

CVE Identifier CVE-2021-42392
GHSA Identifier GHSA-h376-j262-vhq6
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product H2
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-42392

To remediate this vulnerability, upgrade all affected H2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

com.h2database:h2 fixed: 2.0.206
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>2.0.206</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=com.h2database

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-42392, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.h2database

Analyze the terminal output to locate any version of H2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.206), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.h2database command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In H2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://www.jfrog.com/)'s vulnerability research team with detailed information.

CVE-2021-42392 Affected H2 Versions

1 component(s)
Fixed Versions:
2.0.206
Product / Package Ecosystem Affected Versions Fixed Version
com.h2database:h2
Maven
≥ 1.1.100
< 2.0.206
2.0.206

References

Frequently Asked Questions

What is CVE-2021-42392?
CVE-2021-42392 is a security vulnerability in H2 involving RCE in H2 Console under CWE-502: Deserialization of Untrusted Data.
Which H2 versions are affected?
Affected versions include releases prior to 2.0.206 across affected packages: com.h2database:h2.
What version fixes CVE-2021-42392?
Upgrading to 2.0.206 (or the latest patched release for your respective branch) resolves the vulnerability.
Is h2 affected?
Yes, com.h2database:h2 is affected in releases prior to 2.0.206. Upgrade your dependency to 2.0.206 or later.
What is the CVSS score of CVE-2021-42392?
CVE-2021-42392 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-42392?
CVE-2021-42392 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check Maven dependencies for CVE-2021-42392?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.h2database'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-h376-j262-vhq6",
  "modified" : "2022-01-20T15:36:58Z",
  "published" : "2022-01-06T23:55:09Z",
  "aliases" : [ "CVE-2021-42392" ],
  "summary" : "RCE in H2 Console",
  "details" : "### Impact\nH2 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.\n\nH2 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).\n\nIt 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.\n\n### Patches\nSince 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.\n\n### Workarounds\nH2 Console should never be available to untrusted users.\n\n`-webAllowOthers` is a dangerous setting that should be avoided.\n\nH2 Console Servlet deployed on a web server can be protected with a security constraint:\nhttps://h2database.com/html/tutorial.html#usingH2ConsoleServlet\nIf `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.\n\n### References\nThis issue was found and privately reported to H2 team by [JFrog Security](https://www.jfrog.com/)'s vulnerability research team with detailed information.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.h2database:h2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.1.100"
      }, {
        "fixed" : "2.0.206"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/h2database/h2database/security/advisories/GHSA-h376-j262-vhq6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-42392"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/h2database/h2database"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/h2database/h2database/releases/tag/version-2.0.206"
  }, {
    "type" : "WEB",
    "url" : "https://jfrog.com/blog/the-jndi-strikes-back-unauthenticated-rce-in-h2-database-console"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/02/msg00017.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220119-0001"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2022/dsa-5076"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.secpod.com/blog/log4shell-critical-remote-code-execution-vulnerability-in-h2database-console"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-06T20:14:33Z",
    "nvd_published_at" : "2022-01-10T14:10:00Z"
  }
}