Skip to content

Vitess is vulnerable to SQL injection via an unvalidated global SET variable name re-emitted into a VTTablet validation query

High
arthurschreiber published GHSA-m282-7w35-g77m Oct 13, 2026

Software

Vitess

Affected versions

>= 24.0.0, < 24.0.5
< 23.0.8

Patched versions

24.0.5
23.0.8
gomod vitess.io/vitess (Go)
>= 0.24.0, < 0.24.5
< 0.23.8
0.24.5
0.23.8

Description

Summary

An authenticated VTGate client with no special privileges can inject SQL into a validation query VTGate runs on a shard's mysqld by issuing a global-scope SET whose back-tick-quoted variable name cannot be a real system variable. The injected SQL runs on the backing MySQL as the tablet's application user, bypassing VTGate query routing and VTTablet table ACLs.

Details

A global-scope SET (SET @@global.x = ... or SET GLOBAL x = ...) is planned by planSysVarCheckIgnore (go/vt/vtgate/planbuilder/set.go) into an engine.SysVarCheckAndIgnore whose Name is taken directly from the statement:

return &engine.SysVarCheckAndIgnore{
    Name:              expr.Var.Name.Lowered(),
    ...
}

Unlike a session-scope variable, a global variable name is not looked up against the sysvars table, so nothing validates it. SysVarCheckAndIgnore.Execute (go/vt/vtgate/engine/set.go) then builds the validation probe and prints the name unescaped:

checkSysVarQuery := fmt.Sprintf("select 1 from dual where @@%s = %s", svci.Name, svci.Expr)

A back-tick-quoted identifier can contain any character, and the parser splits the global. scope prefix off inside the quotes, leaving the remainder as the variable name. The name is therefore attacker-controlled and is concatenated straight into the probe SQL.

PoC

Any client that can authenticate to VTGate.

SET @@`global.version = 1 union select sleep(5) -- ` = 1;

A planner/executor-level unit test on main (a sandbox tablet records the query VTGate sends) shows the injection:

QUERY SENT TO TABLET:
select 1 from dual where @@version = 1 union select sleep(5) --  = 1

SysVarCheckAndIgnore.Execute discards the probe's result and only logs its errors, so the single-statement primitive is a blind, time/boolean-based SELECT executing as the tablet's MySQL application user (data is inferred through response timing, as with sleep()). The tablet application-pool connection negotiates CLIENT_MULTI_STATEMENTS, so a name that keeps the first statement valid, such as version = 1; DROP TABLE t -- , additionally stacks arbitrary write and DDL statements, which run regardless of the discarded result. This bypasses VTGate routing and planning and VTTablet table ACLs.

Impact

Blind SQL execution as the tablet's MySQL application user, from any authenticated VTGate client, bypassing VTGate routing and VTTablet table ACLs. The single-statement primitive is a blind time/boolean-based read (confidentiality); multi-statement stacking extends it to arbitrary writes and DDL (integrity) and to expensive or destructive statements (availability). Where VTGate authentication is the tenant boundary, that boundary is broken for the targeted shard.

Patches

Fixed in v23.0.8 and v24.0.5 (#21390). VTGate now rejects a global SET whose variable name cannot be a MySQL system variable name: one identifier, or two joined by a single dot as in a component variable (validate_password.length) or a key cache variable (hot$cache.key_buffer_size), each made of letters, digits, underscores and dollar signs. Such a statement fails at planning time with VT05006 (MySQL error 1193, unknown system variable), as it does in MySQL, so the name never reaches a tablet. Every real global variable name still plans as before.

References

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data. Learn more on MITRE.

Improper Encoding or Escaping of Output

The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved. Learn more on MITRE.