CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-63221

CVE-2026-63221: SQL Injection in CodeIgniter4 Query Builder deleteBatch()

Amit Schendel
Amit Schendel
Senior Security Researcher

Aug 8, 2026·8 min read·111 visits

Executive Summary (TL;DR)

CodeIgniter4 versions 4.3.0 through 4.7.3 contain an SQL injection flaw in the Query Builder's deleteBatch() component. When WHERE clauses are chained before a batch delete operation, the system fails to escape bound values, leading to unauthenticated SQL injection.

An SQL injection vulnerability exists in the Query Builder component of the CodeIgniter4 full-stack PHP framework. The vulnerability is located within the compilation logic of the batch delete operation, deleteBatch(). When an application chains where() conditions prior to calling deleteBatch(), the Query Builder fails to enforce or respect the escaping flags of the parameters bound to the WHERE clauses. Instead of passing these parameters through the database driver standard escaping logic, the compilation engine interpolates the raw, unescaped bound values directly into the compiled SQL string, allowing remote attackers to execute arbitrary SQL commands.

Vulnerability Overview

The CodeIgniter4 Query Builder provides an object-oriented interface for generating database queries. A specific design pattern within web applications involves batch processing, where records are updated or deleted in groups using helper methods such as deleteBatch(). To optimize execution, these methods accept arrays of data and combine them with standard Query Builder state filters, including chained where() clauses.

The vulnerability, identified as CVE-2026-63221, resides in how these state filters are combined with the final query. When standard Query Builder filters are applied before a deleteBatch() execution, the database compiler triggers a separate compilation pipeline. Instead of binding these parameters securely or routing them through standard query parametrization interfaces, the database-specific builder classes attempt to manually compile the final SQL string.

This manual compilation leads to a vulnerability class known as improper neutralization of special elements used in an SQL command, classified under CWE-89. The query compilation logic bypasses the active database driver escaping mechanism for filters assigned via standard where clauses. As a result, user-controlled input designed to act as a data value can break out of the SQL syntax context and execute arbitrary database operations.

Root Cause Analysis

To understand the root cause of the flaw, it is necessary to examine how CodeIgniter's Query Builder manages parameter state. When a developer registers a condition using $builder->where('field', $value), the framework generates an internal binding entry. This entry is represented inside the $this->binds associative array, where the key represents the parameter identifier and the value is a indexed array containing two elements: the actual bound value ($bind[0]) and a boolean escape flag ($bind[1]). The escape flag indicates whether the database driver must sanitize and wrap the value in quotes prior to compilation.

In standard SQL compilation paths, such as those executed during a typical delete() or select() operation, the compiler processes this array sequentially and applies driver-specific escaping rules to any bind where the escape flag is active. However, when performing batch deletions, the compilation path diverges. The framework uses driver-specific compilers, such as the _deleteBatch() method located in the core BaseBuilder.php class, as well as dedicated files for drivers like Oracle (OCI8) and PostgreSQL.

Within these batch compilation routines, the framework merges the batch-specific constraints with any prior where conditions. In versions 4.3.0 through 4.7.3, this merge operation was handled by a nested loop that performed a direct string replacement on the query placeholders. The loop extracted the value element directly from the $this->binds array and ran str_replace on the SQL condition template. This replacement completely ignored the state of the escape flag stored in $bind[1] and did not route the raw value through the database connection's character escaping routines. Consequently, the literal unescaped string was embedded directly into the executable query.

Code Analysis

An analysis of the vulnerable source code in system/Database/BaseBuilder.php reveals the exact point where parameter isolation fails. The following snippet illustrates the naive loop implementation before the vulnerability was patched:

// system/Database/BaseBuilder.php (Vulnerable implementation in versions < 4.7.4)
protected function _deleteBatch(string $table, array $keys, array $values): string
{
    // ... [Batch query syntax initialization] ...
 
    // convert binds in where
    foreach ($this->QBWhere as $key => $where) {
        foreach ($this->binds as $field => $bind) {
            // VULNERABILITY: Direct string replacement. $bind[0] contains the raw value.
            // $bind[1] (the escaping boolean) is completely ignored in this iteration.
            $this->QBWhere[$key]['condition'] = str_replace(':' . $field . ':', $bind[0], $where['condition']);
        }
    }
 
    $sql .= ' ' . $this->compileWhereHaving('QBWhere');
    // ...
}

The patch introduced in CodeIgniter 4.7.4 refactors this process. It introduces a dedicated helper method named convertWhereBindsForBatch() which checks the escape flag and utilizes the underlying database connection's escaping capability:

// system/Database/BaseBuilder.php (Patched implementation in version 4.7.4)
protected function _deleteBatch(string $table, array $keys, array $values): string
{
    // ...
    // convert binds in where
    // FIX: Replaced loop with a secure, centralized escaping helper
    $this->convertWhereBindsForBatch();
 
    $sql .= ' ' . $this->compileWhereHaving('QBWhere');
    // ...
}
 
/**
 * Escapes and substitutes the WHERE binds into the QBWhere conditions
 * for batch delete queries.
 */
protected function convertWhereBindsForBatch(): void
{
    $replacers = [];
 
    foreach ($this->binds as $field => $bind) {
        // FIX: The database driver escape() method is called if the escape flag ($bind[1]) is true.
        $escapedValue = $bind[1] ? $this->db->escape($bind[0]) : $bind[0];
 
        if (is_array($bind[0])) {
            $escapedValue = '(' . implode(',', $escapedValue) . ')';
        }
 
        $replacers[':' . $field . ':'] = (string) $escapedValue; // Safe string casting
    }
 
    // FIX: Using strtr() with pre-populated mapping avoids vulnerable double-replacement scenarios.
    foreach ($this->QBWhere as $key => $where) {
        $this->QBWhere[$key]['condition'] = strtr($where['condition'], $replacers);
    }
}

By delegating parameter substitution to convertWhereBindsForBatch(), the system ensures that values containing single quotes or other SQL control characters are safely formatted. For instance, single quotes are doubled up or backslash-escaped according to the specific rules of the database driver in use. Additionally, the replacement mechanism was switched from a nested loop using str_replace to a single-pass strtr function. This prevents double-substitution attacks where an attacker crafts input containing synthetic placeholders to manipulate subsequent replacement steps.

Exploitation Methodology

Exploitation of CVE-2026-63221 requires an endpoint that processes user input and chains it to a query builder context before a batch delete operation. A typical vulnerable pattern occurs in administrative bulk data purges or session clearouts.

Consider a target application processing request parameters to filter batch deletions:

// Example of vulnerable application logic
public function bulkDeleteLogs() 
{
    $filter = $this->request->getPost('filter_value');
    $batchData = [
        ['log_id' => 12,
         'archive_status' => 'pending'],
        ['log_id' => 13,
         'archive_status' => 'pending']
    ];
 
    $builder = $this->db->table('system_logs');
    $builder->setData($batchData, null, 'data')
            ->onConstraint(['log_id' => 'log_id'])
            ->where('log_type', $filter) // Unescaped user input
            ->deleteBatch();
}

If an attacker submits a payload structured to alter the syntax logic, the unescaped interpolation inserts the string verbatim. For instance, the attacker provides the payload ' OR 1=1 --. The Query Builder parses the where condition and compiles the target query. Because the replacement logic uses direct string substitution, the compiled SQL string outputs the following syntax:

DELETE FROM "system_logs" WHERE "system_logs"."log_type" = '' OR 1=1 --' AND "system_logs"."log_id" IN (12, 13)

When processed by the database engine, the OR 1=1 clause evaluates to true for every row in the database table. The SQL comment syntax (--) truncates the remaining constraints generated by the batch processor. As a consequence, the DBMS executes a full table deletion, removing all logs and causing a localized denial of service and loss of database integrity.

Impact Assessment

The impact of CVE-2026-63221 is rated as Critical, with a CVSS v3.1 base score of 9.4. Although the vulnerability resides within a batch delete operation rather than a select operation, the security implications are severe. The primary impact is to system integrity and availability, as unauthorized database modifications can occur without authentication.

In standard configurations, an attacker can exploit this SQL injection vulnerability to destroy arbitrary tables, manipulate administrative user tables, or bypass application constraints. Depending on the underlying database engine and the system's execution privileges, stacked query capabilities could allow the execution of secondary SQL statements. For databases like PostgreSQL or Microsoft SQL Server, this could lead to remote execution of OS commands via system functions (such as xp_cmdshell or external language bindings).

Additionally, because the vulnerability allows the injection of SQL functions, attackers can perform blind, time-based SQL injection to exfiltrate database contents. By substituting data values with conditional evaluation functions (like pg_sleep()), the attacker can read sensitive configuration keys, password hashes, or application records character-by-character based on database response delays.

Remediation and Mitigation

The most secure remediation for this vulnerability is to upgrade the application framework to CodeIgniter version 4.7.4 or later. This release completely addresses the parsing flow in the standard query compiler and driver-specific subclasses.

If upgrading the framework is not immediately possible due to dependency constraints, you can manually apply the patch by editing the base database class. Open system/Database/BaseBuilder.php and locate the _deleteBatch method. Replace the naive foreach loop that performs the str_replace operations with the implementation of convertWhereBindsForBatch() as outlined in the patch analysis.

In addition to upgrading, developers must review applications for unsafe query builder state chaining. As a general security measure, avoid passing raw, unvalidated input directly to Query Builder state methods. Utilize strict input validation schemas (such as alphanumeric regex filters or predefined allowlists) to ensure that only expected query criteria are processed by the database compiler.

Official Patches

CodeIgniter FoundationGitHub Security Advisory GHSA-c9w5-rwh3-7pm9
CodeIgniter FoundationFix Commit f5e463b9a3e986389ce285963e51a7f1fab6559f

Fix Analysis (2)

Technical Appendix

CVSS Score
9.4/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:H
EPSS Probability
0.38%
Top 70% most exploited

Affected Systems

CodeIgniter4 full-stack PHP framework deployments executing on PHP environments

Affected Versions Detail

Product
Affected Versions
Fixed Version
CodeIgniter4
CodeIgniter
>= 4.3.0, < 4.7.44.7.4
AttributeDetail
CWE IDCWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Attack VectorNetwork
CVSS v3.1 Score9.4 (Critical)
EPSS Score0.00377
EPSS Percentile30.46
Exploit MaturityProof of Concept / Analytical
CISA KEV StatusNo

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

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

Known Exploits & Detection

GitHub Security Advisory TestsThe advisory lists clear unit tests reproducing the exact SQL compile outputs showing unescaped strings when where() matches the parameter structure.

Vulnerability Timeline

Initial vulnerability fix commit f5e463b9a3e986389ce285963e51a7f1fab6559f submitted to repository
2026-05-22
Hardening commit 953309e3d1335d449a27c1584805b35f50abea08 added for updateBatch()
2026-06-30
CodeIgniter version 4.7.4 published and Security Advisory GHSA-c9w5-rwh3-7pm9 disclosed
2026-07-31
EPSS Score calculated and published
2026-08-07

References & Sources

  • [1]CVE-2026-63221 Reference Record
  • [2]NVD CVE-2026-63221 Details
  • [3]CodeIgniter4 Security Advisory GHSA-c9w5-rwh3-7pm9
  • [4]CodeIgniter4 Release v4.7.4 Changelog

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 24 hours ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
5 views•10 min read
•1 day ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
11 views•12 min read
•1 day ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
6 views•12 min read
•1 day ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
11 views•10 min read
•1 day ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
14 views•10 min read
•1 day ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
6 views•9 min read