The H2 Database is widely used as a lightweight, fast database engine across various applications. It finds usage among developers for prototyping and testing, while also serving as a backend for many web applications. This database is appreciated for its portability and ease of integration into Java applications. Being an open-source solution, it allows for flexible usage among small to medium scale projects. It comes equipped with a web console for management and query execution, which is particularly used by database administrators. The H2 Database enables efficient storage and retrieval of data by software developers and IT professionals.
The vulnerability identified in the H2 Database involves a pre-authentication remote code execution (RCE). It affects versions from 1.4.198 up to, but not including, 2.1.210. An unauthenticated attacker can exploit this vulnerability by sending specially crafted JDBC URLs. These URLs can bypass the restrictions put in place and execute arbitrary operating system commands. This poses a significant risk as it does not require user interaction, and the impact includes potential full control over the affected systems' operations. The exploit involves manipulating the database's web console, which serves as an entry point for unauthorized actions.
Technical exploitation of this vulnerability involves appending 'FORBID_CREATION=TRUE' to the JDBC URL, ending it with a backslash, and then using a 'CREATE TRIGGER' SQL command. This setup allows running a JavaScript block that triggers the execution of OS commands through the H2 web console. The error response reflects the command output, indicating a successful execution. The vulnerability is particularly present in the JDBC configurations of the vulnerable versions, where misconfiguration allows this exploitation. The role of the 'INIT' trigger in the process highlights a flaw in initialization security of the console. JavaScript used in this context executes code, demonstrating a critical loophole in remote command protection.
Should this vulnerability be exploited by attackers, the effects could be severe. The main consequence is unauthorized command execution in the host system, leading to potential data breaches, system compromise, and downtime. Attackers could gain complete control over the database server, extract sensitive information, and manipulate or delete records. Such access could further be used as a pivot point for lateral movement within an internal network. The host system's integrity and confidentiality stand at risk as attackers may also deploy additional malware or pursue broader exploitation of connected services. This RCE vulnerability essentially provides a backdoor access point into the infrastructure housing the vulnerable software.
REFERENCES
- 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
- Upgrade the H2 Database to version 2.1.210 or later to patch the vulnerability.
- Disable the web console if not necessary, or restrict its access to trusted network locations only.
- Regularly conduct security audits and vulnerability evaluations to identify and rectify similar weaknesses.
- Ensure that any service utilizing H2 Database follows best security practices, including safe configuration and restricted privileges.
- Implement network monitoring to detect unusual activity or access patterns that might suggest exploit attempts.
Get AI-powered remediation steps tailored to your asset.
Try AI Solutions →