/

CVE-2026-59827

Severity:

CRITICAL RISK

(9.9)

Java Deserialization (CWE-502) in Metabase H2 Queries

CVE-2026-59827

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution by authenticated users via unsafe Java object deserialization in H2 query handling.

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Metabase instances using an H2 database connection may unsafely deserialize arbitrary Java objects contained in native query results of type OTHER.

An authenticated user who can run native H2 queries could leverage this behavior to execute arbitrary code on the Metabase server, especially when the default H2 sample database or other H2 connections are enabled.

Affected context

This vulnerability occurs in Metabase deployments that connect to an H2 database, including the built-in sample database. It is specifically triggered when native H2 queries are executed and result sets contain columns of type OTHER that embed serialized Java objects. Metabase deserializes these objects on the server side without sufficient validation, creating risk when users have permissions to issue native queries against an H2-backed data source. Instances using only non-H2 databases or disallowing native queries are less likely to expose this behavior.

Exploit preconditions

  • Attack surface: Metabase web interface or API endpoints that allow executing native H2 queries.
  • Required access: Authenticated Metabase account with permission to run native queries against an H2 database connection (e.g., the sample database or any configured H2 instance).
  • Trigger point: Execution of a crafted native H2 query that causes the database to return a column of type OTHER containing attacker-controlled serialized Java objects.
  • Why exploitation is possible: The server-side query handling code trusts H2 result columns of type OTHER and automatically deserializes their contents using standard Java deserialization mechanisms without validating type safety, provenance, or applying a deserialization whitelist, allowing object graphs that execute code during or after deserialization.

Why this happens

The underlying bug stems from unsafe use of Java deserialization in the database result-handling layer. When processing H2 native query results, Metabase treats columns of type OTHER as serialized Java objects and passes them through a generic deserialization routine. This routine does not enforce a strict allowlist of permissible classes, nor does it treat the returned bytes as untrusted data. In the CWE-502 pattern, attacker-controlled data is fed into a deserializer capable of instantiating arbitrary classes and invoking their readObject or similar hooks, effectively turning data into executable behavior. The absence of validation and object construction controls is what enables the vulnerability.

Potential impact

  • Arbitrary code execution on the Metabase application server by a user who can run native H2 queries.
  • Full compromise of Metabase data, including dashboards, saved questions, and stored credentials for downstream data sources.
  • Lateral movement into connected databases or infrastructure using compromised secrets or trust relationships.
  • Installation of backdoors or persistence mechanisms within the Metabase runtime environment.
  • Use of the Metabase server as a pivot point for broader network compromise or data exfiltration.

General mitigation guidance

Effective mitigation focuses on eliminating unsafe deserialization paths and tightening how database results are processed:

  • Replace generic Java deserialization for H2 columns of type OTHER with safer representations, such as treating them as opaque binary data or mapping them to well-defined, strongly typed structures.
  • Apply strict class allowlists or serialization filters so only expected, harmless types can be deserialized, and reject any unexpected class names or object graphs.
  • Reduce trust in database-returned data by treating all result values as untrusted and ensuring no code paths automatically deserialize them into executable objects.
  • Limit the exposure of native query functionality to the smallest group of users and roles necessary for operations, following least-privilege principles.
  • Isolate Metabase servers with restrictive OS-level permissions and network controls to limit the blast radius if an object deserialization pathway is abused.

How teams detect issues like this

Several complementary strategies can help detect or prevent similar issues:

  • Static analysis: Configure rules to flag use of generic Java deserialization APIs (e.g., ObjectInputStream, readObject) in code that processes data from databases or other external systems, especially around result-set handling logic.
  • Code review: During manual review, pay attention to any logic that deserializes data from database columns, caches, or message queues, and ensure these paths enforce strict type controls and treat inputs as untrusted.
  • Runtime monitoring: Instrument Metabase or surrounding infrastructure to log and alert on unusual native H2 queries, especially those returning columns of type OTHER or containing large/irregular binary payloads.
  • Policy enforcement: Integrate automated security checks into CI/CD that block changes introducing new unsafe deserialization usage patterns, and require security review when adding or modifying database result processing code.

Sources

SourceLink
github.comgithub.com/metabase/metabase/commit/00f42511fe3bc4385652a2e96862ee6fd7d42cf8
github.comgithub.com/metabase/metabase/releases/tag/v0.58.15
github.comgithub.com/metabase/metabase/releases/tag/v0.59.12
github.comgithub.com/metabase/metabase/releases/tag/v0.60.6.3
github.comgithub.com/metabase/metabase/releases/tag/v0.61.1.4
github.comgithub.com/metabase/metabase/security/advisories/GHSA-w95f-x9v9-wv36

Frequently asked

questions

Yes, but only through authenticated access. An attacker must be able to interact with Metabase's HTTP interface or API and have permissions to execute native H2 queries to reach the vulnerable code path.

The attacker needs a Metabase account with rights to run native queries against an H2 data source. Users limited to GUI query builders without native SQL access are less likely to be able to trigger the behavior.

Remove generic Java deserialization from database result handling and instead map database values to explicitly defined, safe types. Where deserialization is unavoidable, enforce strict class allowlists or serialization filters so that only benign, expected classes can ever be instantiated from untrusted data.

Adopt a development policy that treats all externally sourced data, including database results, as untrusted and prohibits automatic deserialization into executable objects. Combine this with static analysis for unsafe deserialization APIs, rigorous code review of serialization logic, and constrained exposure of powerful features like native query execution.

Find out what's already
exploitable in your codebase.