CVE-2022-23221: H2 Arbitrary Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-45hx-wfhj-473x
CVSS 9.8
CWE-88
Published
Advisory Summary

CVE-2022-23221 is a CRITICAL (CVSS 9.8) arbitrary code execution vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting H2 libraries in the Maven ecosystem. The issue involves arbitrary code execution in h2 console. Remediation is available by upgrading affected packages to version 2.1.210.

CVE-2022-23221 at a Glance

CVE Identifier CVE-2022-23221
GHSA Identifier GHSA-45hx-wfhj-473x
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
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-2022-23221

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.1.210
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>2.1.210</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-2022-23221, 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.1.210), 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-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), where the product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string. 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

H2 Console before 2.1.210 allows remote attackers to execute arbitrary code via a jdbc:h2:mem JDBC URL containing the IGNORE_UNKNOWN_SETTINGS=TRUE;FORBID_CREATION=FALSE;INIT=RUNSCRIPT substring, a different vulnerability than CVE-2021-42392.

CVE-2022-23221 Affected H2 Versions

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

References

Frequently Asked Questions

What is CVE-2022-23221?
CVE-2022-23221 is a security vulnerability in H2 involving Arbitrary code execution in H2 Console under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection').
Which H2 versions are affected?
Affected versions include releases prior to 2.1.210 across affected packages: com.h2database:h2.
What version fixes CVE-2022-23221?
Upgrading to 2.1.210 (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.1.210. Upgrade your dependency to 2.1.210 or later.
What is the CVSS score of CVE-2022-23221?
CVE-2022-23221 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-2022-23221?
CVE-2022-23221 is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (The product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.).
How can I check Maven dependencies for CVE-2022-23221?
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-45hx-wfhj-473x",
  "modified" : "2022-01-27T18:28:14Z",
  "published" : "2022-01-21T23:07:39Z",
  "aliases" : [ "CVE-2022-23221" ],
  "summary" : "Arbitrary code execution in H2 Console",
  "details" : "H2 Console before 2.1.210 allows remote attackers to execute arbitrary code via a jdbc:h2:mem JDBC URL containing the IGNORE_UNKNOWN_SETTINGS=TRUE;FORBID_CREATION=FALSE;INIT=RUNSCRIPT substring, a different vulnerability than CVE-2021-42392.",
  "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" : "0"
      }, {
        "fixed" : "2.1.210"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23221"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/h2database/h2database"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/h2database/h2database/releases/tag/version-2.1.210"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/h2database/h2database/security/advisories"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/02/msg00017.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20230818-0011"
  }, {
    "type" : "WEB",
    "url" : "https://twitter.com/d0nkey_man/status/1483824727936450564"
  }, {
    "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.oracle.com/security-alerts/cpujul2022.html"
  }, {
    "type" : "WEB",
    "url" : "http://packetstormsecurity.com/files/165676/H2-Database-Console-Remote-Code-Execution.html"
  }, {
    "type" : "WEB",
    "url" : "http://seclists.org/fulldisclosure/2022/Jan/39"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-88" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-20T16:13:20Z",
    "nvd_published_at" : "2022-01-19T17:15:00Z"
  }
}