Skip to main content
Menu
Advisories

SQL injection in Hibernate json_ HQL functions via Unsanitized Bind Parameters on MySQL/MariaDB

GHSA-V5MR-59HQ-7MVMPublished Updated GitHub

Description

A flaw was found in Hibernate ORM 7.0.0.Beta2 and later, similar to CVE-2026-77874 but affecting only Hibernate ORM's MySQL and MariaDB json_* HQL function renderer.

Details

An application is vulnerable under the following conditions:

  • The application uses Hibernate ORM 8.0.0.Alpha1 or later without any particular setting OR 7.0.0.Beta2 or later while setting the configuration property hibernate.query.hql.json_functions_enabled to true;
  • AND the application connects to MySQL or MariaDB
  • AND the applications executes HQL containing a function call matching json_value(<document reference>, <string expression referencing 'paramName'> passing :pathParam as paramName), where pathParam is a query parameter holding an untrusted string value.

Applications relying on other combinations of targeted databases and HQL function calls are unaffected. In particular, applications relying exclusively on stable, non-incubating features are unaffected.

Applications relying on Hibernate ORM versions 6.x and earlier are unaffected.

Impact

A remote attacker with access to an application that passes unsanitized arguments to incubating JSON-related HQL functions could exploit a first-order SQL injection vulnerability by providing specially crafted values. Successful exploitation can lead to authorization bypass and data exfiltration, enabling the attacker to access information from the database.

Workarounds

  • Upgrade to a fixed version.
  • OR avoid passing untrusted values to path parameters of HQL JSON functions. Instead, use either hardcoded values or sanitized values (apply SQL escapes). Be careful about escaping as improper escaping could still leave the application vulnerable.
  • OR (on Hibernate ORM 7.x) disable HQL JSON functions completely by setting the configuration property hibernate.query.hql.json_functions_enabled to false, or leaving it unset (the default is false). Queries leveraging these functions will then simply error out.

References

Affected versions

References

GitHub · hibernate/hibernate-orm