/

CVE-2026-121007

Severity:

HIGH RISK

(7.3)

SQL Injection (CWE-89) in Perl SQL::Abstract Queries

CVE-2026-121007

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Potential unauthorized database access or modification

Severity:

HIGH RISK

(7.3)

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

SQL::Abstract can mishandle values in certain nested statements, placing values from clauses such as where, having, and set into generated SQL instead of the bind list. If an application supplies untrusted input in those positions expecting it to be bound, the input may alter the SQL query; subselects in a WHERE condition are not affected.

Affected context

The issue affects applications using SQL::Abstract versions from 1.90_01 before 2.000001_04 when they build nested statements in identifier positions, including the select list, ORDER BY, GROUP BY, and RETURNING. With the ExtraClauses plugin, affected positions also include FROM (-as) and JOIN (to). Risk arises when untrusted input is supplied as a value in a nested statement and the application expects it to be safely bound; subselects in a WHERE condition are not affected.

Exploit preconditions

  • Attack surface: Application code that constructs SQL using SQL::Abstract nested statements in an affected identifier position.
  • Required access: Ability to influence input used as a where value within such a nested statement; direct database or server access is not necessarily required.
  • Trigger point: The application generates or executes a query containing the affected nested statement.
  • Why exploitation is possible: Some nested-statement values are inserted into SQL text rather than the bind list, and may be unescaped when quote_char is not set.

Why this happens

The query builder does not consistently preserve value-binding semantics when processing nested statements in identifier positions. Plain scalars in the nested statement are treated as identifiers, while values from clauses such as where, having, set, and -values can be emitted into SQL text instead of being represented as bound parameters. This is a SQL injection weakness (CWE-89) because input that an application expects to be treated as data can affect the structure or meaning of a query.

Potential impact

  • An attacker may alter the meaning of queries that include attacker-influenced values.
  • Depending on the query and database permissions, data could be disclosed, modified, or deleted.
  • Database availability or integrity could be affected.

General mitigation guidance

Defensive approaches focus on preserving the distinction between SQL structure and data:

  • Use query-building patterns that bind values consistently, including within nested statements.
  • Treat identifiers and other SQL structure as trusted inputs; select them from explicit allowlists rather than accepting arbitrary user input.
  • Validate nested query structures against an expected schema before building or executing SQL.
  • Apply least-privilege permissions to database accounts so query execution is limited to necessary operations.
  • Avoid relying on quoting alone as a substitute for parameter binding and input validation.

How teams detect issues like this

Review query-building code for nested statements in identifier positions and trace whether user-controlled values reach their where, having, set, or -values clauses. Static analysis and code review can flag SQL construction that places values into query text rather than a bind list, as well as identifiers derived directly from untrusted input. CI policies can require parameter binding for values and allowlist validation for SQL identifiers.

Sources

SourceLink
github.comgithub.com/dbsrgits/sql-abstract/commit/79fc34e874b4edb441154eccddb04c57d5c1c90e.patch
metacpan.orgmetacpan.org/release/GETTY/SQL-Abstract-2.000001_04/changes

Frequently asked

questions

The issue is in SQL query construction. Network exploitation may be possible if an application accepts attacker-controlled input and uses it in an affected nested statement.

An attacker needs a way to influence a value used in a vulnerable query path. Whether authentication is required depends on the application exposing that path.

Ensure values are passed as bind parameters throughout nested queries, and allowlist any input used to select identifiers or other SQL structure.

Review query construction paths for consistent binding, validate nested query shapes, and use code review or automated checks to detect values interpolated into SQL text.

Find out what's already
exploitable in your codebase.