The H2 database contains an alias function which allows for arbitrary Java code to be used. This functionality can be abused to create an exec functionality to pull our payload down and execute it. H2's web interface contains restricts MANY characters, so injecting a payload directly is not favorable. A valid database connection is required. If the database engine was configured to allow creation of databases, the module default can be used which utilizes an in memory database. Some Docker instances of H2 don't allow writing to folders such as /tmp, so we default to writing to the working directory of the software. This module was tested against H2 version 2.1.214, 2.0.204, 1.4.199 (version detection fails)
Exploit database
Vulnerability
CVE-2018-10054
Vulnerability details
- Score
- 8.8
- Severity
- high
CVSS 3.1 · NVD
Vector string
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HDescription
H2 1.4.197, as used in Datomic before 0.9.5697 and other products, allows remote code execution because CREATE ALIAS can execute arbitrary Java code. NOTE: the vendor's position is "h2 is not designed to be run outside of a secure environment."
CVE ProgramExploit source choices
1 sourceH2 Web Interface Create Alias RCE
2018-04-09h2_webinterface_rce.rb