CWE-564 詳細

CWE-564

Use of Hibernate with HQL/SQL Query String Containing External Input
2006-07-19
00h00 +00:00
Incomplete
2026-10-28
00h00 +00:00
特定のCWEの通知
特定のCWEの変更情報をいち早くお届けします。
通知を管理する

名前: Use of Hibernate with HQL/SQL Query String Containing External Input

The product uses Hibernate to execute a dynamic HQL or SQL statement, but the statement is built with user-controlled input.

一般情報

導入モード

Architecture and Design
Implementation

適用可能なプラットフォーム

言語

名前: SQL (Often)

テクノロジー

名前: Database Server (Undetermined)

一般的な結果

スコープ 影響 可能性
Confidentiality
Integrity
Read Application Data, Modify Application Data

注記:If an attacker can insert input directly into the SQL query string, even when the string contains parameter bindings, an attacker can modify the statement's structure and meaning, possibly execute arbitrary SQL commands (i.e., SQL injection).

観察された例

参考文献 説明

CVE-2025-52472

wiki platform REST API allows HQL injection via select and order clauses.

CVE-2023-26093

middleware allows HQL injection via sort columns.

CVE-2016-1595

file download functionality in service desk software allows HQL injection via user-controlled parameters

潜在的な緩和策

Phases : Requirements
A non-SQL style database that is not subject to this flaw may be chosen.
Phases : Architecture and Design
Follow the principle of least privilege when creating user accounts to a SQL database. Users should only have the minimum privileges necessary to use their account. If the requirements of the system indicate that a user can read and modify their own data, then limit their privileges so they cannot read/write others' data.
Phases : Architecture and Design
For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Phases : Implementation
Implement SQL strings using prepared statements that bind variables. Prepared statements that do not bind variables can be vulnerable to attack.
Phases : Implementation
Use vigorous allowlist style checking on any user input that may be used in a SQL command. Rather than escape meta-characters, it is safest to disallow them entirely. Reason: Later use of data that have been entered in the database may neglect to escape meta-characters before use. Narrowly define the set of safe characters based on the expected value of the parameter in the request.

検出方法

Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
有効性 : High

脆弱性マッピングノート

理由 : This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
コメント : Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

関連する攻撃パターン

CAPEC ID 攻撃パターン名
CAPEC-109 Object Relational Mapping Injection
An attacker leverages a weakness present in the database access layer code generated with an Object Relational Mapping (ORM) tool or a weakness in the way that a developer used a persistence framework to inject their own SQL commands to be executed against the underlying database. The attack here is similar to plain SQL injection, except that the application does not use JDBC to directly talk to the database, but instead it uses a data access layer generated by an ORM tool or framework (e.g. Hibernate). While most of the time code generated by an ORM tool contains safe access methods that are immune to SQL injection, sometimes either due to some weakness in the generated code or due to the fact that the developer failed to use the generated access methods properly, SQL injection is still possible.

ノート

This weakness might be referred to as "SQL injection" because Hibernate processes HQL queries by translating them into SQL queries. However, HQL is a distinct language.

参考文献

REF-1559

Hibernate
OWASP.
https://community.owasp.org/Hibernate

REF-1560

Hibernate Query Language (HQL) Injection
Invicti.
https://www.invicti.com/web-application-vulnerabilities/hibernate-query-language-hql-injection

REF-1534

Automated Technical Debt Measure, Version 2
OMG.
https://www.omg.org/spec/ATDM2/1.0/PDF

登録情報

名前 組織 日付 リリース日 Version
Anonymous Tool Vendor (under NDA) 2006-07-19 +00:00 2006-07-19 +00:00 Draft 3

変更履歴

名前 組織 日付 コメント
Sean Eidemiller Cigital 2008-07-01 +00:00 added/updated demonstrative examples
Eric Dalci Cigital 2008-07-01 +00:00 updated Time_of_Introduction
CWE Content Team MITRE 2008-09-08 +00:00 updated Relationships, Taxonomy_Mappings
CWE Content Team MITRE 2009-05-27 +00:00 updated Related_Attack_Patterns
CWE Content Team MITRE 2010-06-21 +00:00 updated Potential_Mitigations
CWE Content Team MITRE 2011-06-01 +00:00 updated Common_Consequences
CWE Content Team MITRE 2012-05-11 +00:00 updated Relationships
CWE Content Team MITRE 2012-10-30 +00:00 updated Potential_Mitigations
CWE Content Team MITRE 2013-07-17 +00:00 updated Relationships
CWE Content Team MITRE 2014-07-30 +00:00 updated Relationships, Taxonomy_Mappings
CWE Content Team MITRE 2017-05-03 +00:00 updated Potential_Mitigations
CWE Content Team MITRE 2017-11-08 +00:00 updated Taxonomy_Mappings
CWE Content Team MITRE 2018-03-27 +00:00 updated Relationships
CWE Content Team MITRE 2020-02-24 +00:00 updated Relationships
CWE Content Team MITRE 2020-06-25 +00:00 updated Potential_Mitigations
CWE Content Team MITRE 2020-08-20 +00:00 updated Relationships
CWE Content Team MITRE 2021-10-28 +00:00 updated Relationships
CWE Content Team MITRE 2023-04-27 +00:00 updated Relationships
CWE Content Team MITRE 2023-06-29 +00:00 updated Mapping_Notes
CWE Content Team MITRE 2025-04-03 +00:00 updated Applicable_Platforms
CWE Content Team MITRE 2025-12-11 +00:00 updated Relationships, Weakness_Ordinalities
CWE Content Team MITRE 2026-10-28 +00:00 updated Alternate_Terms, Common_Consequences, Demonstrative_Examples, Description, Detection_Factors, Name, Observed_Examples, Potential_Mitigations, References, Terminology_Notes