/

CVE-2026-49845

Severity:

CRITICAL RISK

(9.8)

SQL Injection (CWE-94) in Hive Metastore Direct SQL

CVE-2026-49845

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-94

Impact:

Unauthorized partition metadata access and manipulation

Severity:

CRITICAL RISK

(9.8)

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

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.

Sources

SourceLink
github.comgithub.com/apache/hive
github.comgithub.com/apache/hive/commit/ca64f08a8e43db9845b47d5fa2e96f7fdea7288e
issues.apache.orgissues.apache.org/jira/browse/HIVE-29622
lists.apache.orglists.apache.org/thread/6d56mk501fp4f8cb5wvrpj2jwd9knt05

Frequently asked

questions

Exploitation generally requires an authenticated or network-trusted caller

that can invoke relevant Hive Metastore partition APIs against a table it can

reference.

Not by itself. The primary scope is unintended partition targeting within

tables available through the caller's existing Metastore permissions.

Use parameterized SQL or a trusted query-construction abstraction for every

client-controlled partition value, combined with strict input validation.

Enforce parameterized-query policies in code review and CI, test partition

APIs with adversarial input, and apply least-privilege authorization to

Metastore operations.

Find out what's already
exploitable in your codebase.