Summary
A SQL injection vulnerability in Apache Hive's Hive Metastore can allow an authenticated user to alter partition-name queries through crafted partition names. When direct SQL is enabled, this may cause reads, updates, truncation, or cache operations to target unintended partitions within an accessible table.
Affected context
The issue occurs in Hive Metastore deployments that use direct SQL for partition-name resolution, which is enabled by default in the affected configuration. It affects RPC paths that embed client-provided full partition names into SQL statements, particularly when callers can reach partition-related APIs directly or through Hive-compatible clients.
Exploit preconditions
- Attack surface: Hive Metastore RPC APIs that resolve partitions by full
partition name
- Required access: An authenticated or network-trusted caller permitted to
invoke relevant Metastore operations
- Trigger point: Processing of a crafted partition name while direct SQL is
enabled
- Why exploitation is possible: The partition name is concatenated into a SQL
predicate rather than passed as a bound parameter, allowing the generated
WHERE clause to be altered
Why this happens
The underlying flaw is unsafe construction of SQL statements from client-controlled partition names. Direct-SQL helper logic treats the input as a quoted SQL string and concatenates it into a query instead of using parameter binding or an equivalent safe query construction mechanism. This allows input containing SQL control characters to change predicate semantics, corresponding to injection into dynamically constructed statements under CWE-94.
Potential impact
- An attacker may read metadata for unintended partitions in a referenced table.
- An attacker could cause statistics updates to affect additional partitions.
- Truncation or related data-management operations may target unintended partitions.
- Metadata-cache operations could be applied to partitions not selected by the caller.
- Partition metadata integrity may be reduced within tables the caller can reference.
General mitigation guidance
Mitigation generally focuses on eliminating string concatenation between client-controlled values and SQL statements. Secure-by-default patterns include bound parameters, well-tested query builders, and narrowly scoped APIs that do not accept ambiguous free-form identifiers. Input trust should be reduced through canonical partition-name parsing, strict validation, and allowlisted structural formats before database use. Direct SQL paths should have equivalent validation and authorization controls, while Metastore services and database identities should operate with least privilege.
How teams detect issues like this
Detection can include static analysis for SQL construction through string concatenation, especially in helpers that quote or escape RPC parameters manually. Code review should examine every partition-name query path and verify that values use bind parameters consistently. Runtime monitoring can flag unusual partition predicates, unexpected multi-partition effects, and metadata operations that exceed a caller's normal scope. CI policies may require parameterized queries and automated security review tools can help identify unsafe data-to-query flows.

