Summary
Metabase contains a code injection flaw in one H2 database creation path where unsafe connection properties are not validated. This allows an authenticated administrator to register a crafted H2 connection and trigger arbitrary Java code execution on the Metabase server.
The vulnerability becomes critical wherever admin-level users can define H2 connections and the Metabase application runs with high privileges or broad network access.
Affected context
The issue occurs in Metabase deployments that use the affected versions and allow creation of H2 database connections through the administrative interface.
It is specifically tied to a database-creation code path that passes user-supplied H2 connection properties to the underlying driver without sufficient validation.
The risk is highest in environments where Metabase is exposed to multiple administrators or integrated into a broader analytics platform with elevated server privileges.
Exploit preconditions
- Attack surface: Metabase server-side database configuration functionality
- Required access: Authenticated Metabase administrator account able to add or modify database connections
- Trigger point: Creation of a new H2 database connection using crafted connection properties in the vulnerable code path
- Why exploitation is possible: The application fails to validate or restrict dangerous H2 connection parameters, allowing the database driver to interpret attacker-controlled values that can lead to arbitrary Java code execution
Why this happens
The root cause lies in treating database connection properties as inherently safe configuration rather than untrusted input.
In the vulnerable Metabase code path, user-controlled H2 connection settings are forwarded to the driver without filtering for known-dangerous options or enforcing a strict allowlist. Certain H2 features permit embedding executable expressions or loading classes, which the driver processes at connection time.
This behavior maps to CWE-94: Improper Control of Generation of Code, where attacker-controlled data influences code that is executed, in this case via the database engine's configuration mechanisms.
Potential impact
- An authenticated administrator may execute arbitrary Java code on the Metabase server
- Attackers could gain full control over the Metabase application process and its data
- Compromise of credentials or API keys stored or managed by Metabase
- Lateral movement into other systems reachable from the Metabase host
- Disruption of analytics services through data tampering or service denial
General mitigation guidance
Effective mitigation focuses on constraining how configuration values reach executable components and reducing the trust assigned to administrative inputs:
- Apply strict allowlisting to database connection properties, only permitting parameters required for safe operation
- Normalize the treatment of administrative configuration as untrusted input, subject to validation and sanitization
- Disable or restrict database engine features that permit code execution, class loading, or script evaluation where possible
- Run Metabase with least-privilege OS and network permissions so that, even if code runs, its blast radius is reduced
- Separate high-risk configuration capabilities (such as custom driver properties) from general administrative tasks, or gate them behind additional approvals
How teams detect issues like this
Organizations can detect similar issues and misuse patterns by:
- Using static analysis to flag direct propagation of configuration parameters into database or driver APIs without validation
- Reviewing database integration code for unbounded property passing, especially with engines known to support scripting or class loading
- Implementing policy checks in code review and CI that require allowlists for connection properties and disallow known-dangerous options
- Monitoring Metabase logs and runtime telemetry for unusual or rarely used H2 connection parameters associated with new database registrations
- Employing application security testing tools that exercise administrative configuration flows, not just end-user queries

