/

CVE-2026-119418

Severity:

HIGH RISK

(8.1)

SQL Injection (CWE-89) in CakePHP WindowExpression

CVE-2026-119418

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized SQL execution and database compromise

Severity:

HIGH RISK

(8.1)

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

CakePHP through 5.4.3 contains a SQL injection vulnerability in window-expression handling when frame offsets and directions are not properly validated. If an application forwards attacker-controlled values into the SQL OVER clause, an attacker may alter generated SQL and execute statements with the database connection's privileges.

CakePHP through 5.4.3 contains a SQL injection vulnerability in window-expression handling when frame offsets and directions are not properly validated. If an application forwards attacker-controlled values into the SQL OVER clause, an attacker may alter generated SQL and execute statements with the database connection's privileges.

Affected context

The issue occurs in applications using CakePHP's WindowExpression::range() or frame() methods to construct window functions. Risk is present when user-controlled or otherwise untrusted frame offsets and directions reach these methods without strict allowlisting, type validation, or query-construction safeguards.

The issue occurs in applications using CakePHP's WindowExpression::range() or frame() methods to construct window functions. Risk is present when user-controlled or otherwise untrusted frame offsets and directions reach these methods without strict allowlisting, type validation, or query-construction safeguards.

Exploit preconditions

  • Attack surface: Application endpoints or services that build SQL window expressions through CakePHP
  • Required access: Ability to influence request or other input values forwarded to frame offsets or directions
  • Trigger point: Generation and execution of a query containing an affected OVER clause
  • Why exploitation is possible: Unvalidated expression components may be incorporated into SQL syntax rather than treated only as constrained values
  • Attack surface: Application endpoints or services that build SQL window expressions through CakePHP
  • Required access: Ability to influence request or other input values forwarded to frame offsets or directions
  • Trigger point: Generation and execution of a query containing an affected OVER clause
  • Why exploitation is possible: Unvalidated expression components may be incorporated into SQL syntax rather than treated only as constrained values

Why this happens

The underlying bug is insufficient validation of SQL expression components supplied to WindowExpression::range() and frame(). When application-controlled strings are accepted as frame offsets or directions and incorporated into generated SQL, attackers may influence query structure. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL injection.

The underlying bug is insufficient validation of SQL expression components supplied to WindowExpression::range() and frame(). When application-controlled strings are accepted as frame offsets or directions and incorporated into generated SQL, attackers may influence query structure. This behavior maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL injection.

Potential impact

  • An attacker may read unauthorized database records
  • An attacker could modify or delete application data
  • Database credentials or sensitive metadata may be exposed
  • SQL statements could execute with the privileges of the configured database account
  • Availability may be affected through destructive or resource-intensive queries
  • An attacker may read unauthorized database records
  • An attacker could modify or delete application data
  • Database credentials or sensitive metadata may be exposed
  • SQL statements could execute with the privileges of the configured database account
  • Availability may be affected through destructive or resource-intensive queries

General mitigation guidance

Mitigation generally focuses on preventing untrusted input from controlling SQL syntax.

Common defensive patterns include:

  • Use allowlisted, typed representations for frame directions and offsets
  • Prefer secure-by-default query APIs that separate SQL structure from data values
  • Reject unexpected, oversized, or malformed inputs before query construction
  • Avoid forwarding request parameters directly into window-expression builders
  • Apply least privilege to database accounts and limit access to unnecessary schemas and operations
  • Add centralized validation and authorization controls around query-building boundaries

Mitigation generally focuses on preventing untrusted input from controlling SQL syntax.

Common defensive patterns include:

  • Use allowlisted, typed representations for frame directions and offsets
  • Prefer secure-by-default query APIs that separate SQL structure from data values
  • Reject unexpected, oversized, or malformed inputs before query construction
  • Avoid forwarding request parameters directly into window-expression builders
  • Apply least privilege to database accounts and limit access to unnecessary schemas and operations
  • Add centralized validation and authorization controls around query-building boundaries

How teams detect issues like this

Detection approaches commonly include:

  • Static analysis rules for request data reaching WindowExpression::range() or frame()
  • Code review checks for dynamic SQL fragments, unchecked strings, and missing allowlists
  • Runtime monitoring for anomalous SQL syntax, unexpected window clauses, and unusual database errors
  • Database activity monitoring to identify unauthorized reads, writes, or schema changes
  • Policy enforcement requiring parameterization or constrained enums for SQL expression inputs
  • Automated security review tools that flag tainted data flows into query construction

Detection approaches commonly include:

  • Static analysis rules for request data reaching WindowExpression::range() or frame()
  • Code review checks for dynamic SQL fragments, unchecked strings, and missing allowlists
  • Runtime monitoring for anomalous SQL syntax, unexpected window clauses, and unusual database errors
  • Database activity monitoring to identify unauthorized reads, writes, or schema changes
  • Policy enforcement requiring parameterization or constrained enums for SQL expression inputs
  • Automated security review tools that flag tainted data flows into query construction

Sources

SourceLink
abraxaslabs.techabraxaslabs.tech/research/cakephp-window-sqli
github.comgithub.com/cakephp/cakephp
github.comgithub.com/cakephp/cakephp/blob/6f3dd91371ac0698b64024ddb21d57def9fbba91/src/Database/Expression/WindowExpression.php#L152
github.comgithub.com/cakephp/cakephp/blob/6f3dd91371ac0698b64024ddb21d57def9fbba91/src/Database/Expression/WindowExpression.php#L330
github.comgithub.com/cakephp/cakephp/commit/18de3e4cdabba049269421bf43c2ccd1a7451565
github.comgithub.com/cakephp/cakephp/commit/3c1183fb62274c8a1c2780b2d3cc40f40cf31f1f
github.comgithub.com/cakephp/cakephp/commit/a5ca1748dcdb432631fc2760f898576043ce3df9
github.comgithub.com/cakephp/cakephp/pull/19735
vulncheck.comvulncheck.com/advisories/cakephp-through-5.4.3-sql-injection-via-windowexpression-range-and-frame

Frequently asked

questions

It may be remotely exploitable when a reachable application endpoint accepts attacker-controlled values and forwards them into affected window-expression methods.

The attacker generally needs access to an input path that influences frame offsets or directions. Authentication may or may not be required, depending on the application's endpoint and authorization model.

Treat frame directions and offsets as constrained query structure: use strict types or allowlists, reject invalid values, and prevent raw user input from being inserted into SQL expressions.

Combine parameterized query construction with taint-aware code review, centralized input validation, least-privileged database accounts, and monitoring for unexpected SQL activity.

It may be remotely exploitable when a reachable application endpoint accepts attacker-controlled values and forwards them into affected window-expression methods.

The attacker generally needs access to an input path that influences frame offsets or directions. Authentication may or may not be required, depending on the application's endpoint and authorization model.

Treat frame directions and offsets as constrained query structure: use strict types or allowlists, reject invalid values, and prevent raw user input from being inserted into SQL expressions.

Combine parameterized query construction with taint-aware code review, centralized input validation, least-privileged database accounts, and monitoring for unexpected SQL activity.

Find out what's already
exploitable in your codebase.