close
Skip to content

SQL injection in Query Builder deleteBatch() when used with where() conditions

Critical
paulbalandan published GHSA-c9w5-rwh3-7pm9 Jul 7, 2026

Package

composer codeigniter4/framework (Composer)

Affected versions

>= 4.3.0, < 4.7.4

Patched versions

4.7.4

Description

Impact

A SQL injection vulnerability exists in the Query Builder's deleteBatch() method. When deleteBatch() is used together with where() conditions, the bound values from the WHERE clause are substituted directly into the generated SQL with their escape flag ignored, so they are never escaped or quoted. If an application passes user-controlled input to where() before calling deleteBatch(), that input is interpreted as SQL rather than as a value, allowing SQL injection.

This affects only the deleteBatch() code path. Regular delete() operations escape where() binds correctly.

Patches

Upgrade to v4.7.4 or later.

Workarounds

If you cannot upgrade immediately:

  • Strictly validate and cast values (e.g. numeric IDs) before using them in conditions - though this does not fully protect string conditions.
  • Do not pass user-controlled input to where() when using deleteBatch().
  • For user-controlled conditions, use a normal delete() with Query Builder binds instead of deleteBatch().
  • Where possible, express required matching values through the batch data and onConstraint() rather than as separate user-controlled where() clauses.

References

Severity

Critical

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
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
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:N/UI:N/S:U/C:L/I:H/A:H

CVE ID

CVE-2026-63221

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.

Credits