Hibernate JSON HQL functions can carry SQL injection into MySQL and MariaDB

Hibernate ORM is a persistence layer used by many Java applications to build queries without hand-writing every database statement. CVE-2026-133442 affects the json_* HQL functions when a path parameter contains untrusted data on MySQL or MariaDB. The database then receives a statement that can change query meaning.

Affected ranges include Hibernate ORM 7.0.0.Beta2 through 7.2.25.Final, 7.3.0.CR1 through 7.4.16.Final, and 8.0.0.Alpha1 through 8.0.0.CR1. Fixed releases are 7.2.26.Final, 7.4.17.Final and 8.0.0.CR2.

The boundary that fails

HQL JSON functions use path expressions to reach a value inside a JSON document. The path is part of the query syntax, not an ordinary bind value. If an application concatenates user input into that path, Hibernate may not treat the result as inert data when generating SQL for MySQL or MariaDB.

An attacker who can influence the path may append syntax that changes the surrounding statement. The practical result depends on the application's query, database permissions and whether results are returned. IBM describes the issue as SQL injection with possible viewing, addition, modification or deletion of backend data. IBM's CVSS vector requires low privileges, so the exploit path may begin with an authenticated application feature rather than an anonymous endpoint.

Why bind parameters alone may not be enough

The advisory recommends avoiding untrusted values in HQL JSON path parameters. Hardcoded or explicitly sanitized values are safer. The wording also warns that improper escaping can remain vulnerable. Applications that use string concatenation inside a path expression therefore need to inspect the exact query builder as well as the bind parameters nearby.

Hibernate 7.x users can disable HQL JSON functions with hibernate.query.hql.json_functions_enabled=false. The default is false in the affected line, but deployments that enabled the feature should verify the effective configuration. Queries that depend on the feature will fail when it is disabled, which is a visible but safer operational choice.

Remediation

Upgrade to a fixed Hibernate ORM release. Search code for json_* HQL functions and trace every path argument to its source. Replace user-controlled paths with fixed paths for the query's purpose. If the use case requires dynamic keys, validate against an explicit map of allowed paths before constructing the query, and use a second layer of database least privilege.

Review database logs for unusual syntax near JSON path functions, changes outside the application's normal tables and errors caused by altered query structure. Application logs may show a valid object lookup while the database executed a broader statement. Preserve both layers during triage.

References