Skip to main content

Cloudsoft Zone Build, deploy and scale with practical guides to PHP, Node.js, React, DevOps and AI automation. Explore the guides

Cloudsoft Zone
CodeIgniterIndustry update

CodeIgniter 4.7.6 security release: what to patch and how

CodeIgniter 4.7.6 fixes four security advisories: SQL injection through named binds, a mass assignment bypass in Model::replace(), and path traversal in the file cache and sanitize_filename(). Who is exposed, what changes in behaviour, and how to upgrade from 4.7.5.

Nilesh Kushvaha

6 min read

Cloudsoft Zone cover: CodeIgniter 4.7.6 security release
Image: Cloudsoft Zone
In this article

The CodeIgniter 4.7.6 security release of 1 November 2026 patches four advisories: one rated high, an SQL injection through named query bindings, and three rated medium, covering Model::replace(), the file cache and sanitize_filename(). Every advisory lists version 4.7.5 and earlier as affected and 4.7.6 as the fix, so any CodeIgniter 4 application should plan the upgrade now.

Three of the fixes change behaviour, and the release also repairs two regressions from earlier 4.7 releases. This guide explains each advisory in plain terms, shows who is actually exposed, and walks through the upgrade and the checks to run afterwards. Everything here comes from the official 4.7.6 change log, the upgrade guide and the GitHub security advisories published the same day.

The CodeIgniter 4.7.6 security release at a glance

AdvisorySeverityComponentWhat was wrong
GHSA-25rf-99hr-7pmrHigh (CVSS 8.1)Database, named bindsA named bind placeholder inside an already escaped value was replaced, which could break out of a string literal
GHSA-jv74-fx4h-m63xMedium (6.5)Model::replace()Field protection was not applied, so untrusted input could write columns outside $allowedFields
GHSA-9hf2-g3w9-pfmpMedium (6.5)Cache FileHandler::deleteMatching()A pattern such as ../* could delete files outside the cache directory
GHSA-9j59-qcxw-q7qmMedium (4.8)sanitize_filename()Backslash sequences survived filtering, so input such as .\\./ could become ../

None of the four advisories carried a CVE number when this was written; refer to them by their GHSA identifiers.

1. SQL injection through named binds (high)

CodeIgniter supports named binds, written :name:. Before 4.7.6 a placeholder was replaced wherever it appeared in the final SQL, including inside a value that had already been escaped and rendered into the query. If that value contained text that looked like another placeholder, the second bind was substituted inside the string literal and could break out of it.

You are exposed if a query combines named binds with one of these:

  • a subquery passed to where(), union(), fromSubquery() or selectSubquery();
  • a custom where() string built with $db->escape();
  • the WHERE binds of deleteBatch();
  • a manually escaped fragment in $db->query().

Plain where(), like(), insert() and update() calls were not affected. From 4.7.6 placeholders are ignored inside quoted strings, quoted identifiers and SQL comments, which is how question-mark binds have always behaved.

Behaviour change. A query that disabled escaping for a bind and relied on the placeholder being replaced inside quotes now keeps the placeholder as literal text. The upgrade guide gives this example, which used to search for %Rick% and now searches for the literal string %:name:%:

PHP
// Before: placeholder inside quotes, escaping switched off
$db->query("SELECT * FROM users WHERE name LIKE '%:name:%'", ['name' => ['Rick', false]], false);

// After: put the wildcards in the bound value and let it be escaped as a whole
$db->query('SELECT * FROM users WHERE name LIKE :name:', ['name' => '%Rick%']);

2. Model::replace() now applies field protection (medium)

insert() and update() have always discarded fields that are not in $allowedFields. replace() did not, so an application that passed request data to it could have protected columns overwritten. From 4.7.6:

  • with protection enabled, fields outside $allowedFields are discarded, except a supplied primary key;
  • input that filtering reduces to nothing, or to only its primary key, throws a DataException;
  • a trusted operation that must write other columns has to switch protection off explicitly, and back on afterwards.
PHP
// A trusted import that writes a column outside $allowedFields
$model->protect(false)->replace($row);
$model->protect(true);

Check every replace() call: either the columns it writes are in $allowedFields, or the call is a trusted one and should disable protection on purpose.

3. File cache deleteMatching() stays inside the cache directory (medium)

FileHandler::deleteMatching() used to append the pattern to the cache path and pass it to glob(), so a pattern containing a directory separator could reach other directories. It now matches the pattern against the names of files in the cache directory only. A pattern such as dir/key_* now matches nothing and returns 0.

Most applications are not affected: the File handler stores every item directly in the cache directory, and the default reserved characters forbid / and \\ in cache keys. You are affected only if your own code keeps files in subdirectories of the cache directory and removed them with deleteMatching(); delete those directly instead, for example with the delete_files() helper. The risk before the fix was real only where a pattern was built from user input.

4. sanitize_filename() removes every backslash (medium)

sanitize_filename() and Security::sanitizeFilename() removed backslashes only in a final step, after filtering. With $relativePath set to true, input such as .\\./ became ../; repeated backslashes could survive as Windows path separators, and \\0 could become a NUL byte. Backslashes are now removed during filtering.

Ordinary file names and relative paths with forward slashes give the same result as before. Results can differ for repeated backslashes and literal \\0 sequences. If your application stores or compares sanitised file names, check for changed results and possible collisions, and use forward slashes for relative paths, on Windows too.

How to upgrade from 4.7.5

Shell
composer update codeigniter4/framework
composer show codeigniter4/framework | grep versions    # should show 4.7.6

For a manual installation, replace the system directory with the one from the 4.7.6 download. The upgrade guide lists no changed config files for this release, so there is nothing in app/Config to merge.

Then find the code the three behaviour changes touch:

Shell
grep -rnE -e "->replace\(|deleteMatching\(|sanitize_filename\(|sanitizeFilename\(" app
grep -rnE ":[A-Za-z_]+:" app | grep -E "query\(|RawSql"     # named binds in raw queries

The second search is rough. Read each hit and check whether a placeholder sits inside quotes or a bind has escaping switched off. Run your test suite, then exercise by hand any import or sync job that uses replace() and any upload that sanitises file names.

If you are still on 4.7.4 or older, you also need the fixes from the previous release: see the CodeIgniter 4.7.5 security release guide.

Other fixes worth knowing about

  • set_value() no longer throws a TypeError when the default is an integer, a float or null. This was a regression in 4.7.5.
  • After a MySQL deadlock (error 1213) a following write on the same connection no longer autocommits, and transCommit() rolls back and returns false.
  • reconnect() no longer keeps a transaction that died with the old connection.
  • ContentSecurityPolicy::reportOnly() called after the policy was created now applies to sources from the config file, a regression since 4.7.0.
  • IncomingRequest::isSecure() recognises https in X-Forwarded-Proto from a trusted proxy when the value has capital letters or surrounding spaces.
  • Time objects keep their time zone and locale after unserialize(), a regression since 4.7.1.
  • A JSON request body that is an array is no longer corrupted after CSRF verification when the token is sent in the X-CSRF-TOKEN header.

Two small additions: ContentSecurityPolicy::addDefaultSrc() appends sources to default-src, and FileVarExportHandler accepts a custom cache path. BaseBuilder::convertWhereBindsForBatch() is deprecated and no longer used.

What to do next

  1. Upgrade to 4.7.6 in a branch and run the tests.
  2. Review the named-bind, replace(), deleteMatching() and file name code found by the searches above.
  3. Deploy, then watch the logs for DataException from replace() calls you missed.

For the wider hardening steps around a release, see the CodeIgniter 4 production deployment and security checklist. If you have not moved to 4.7 yet, start with what is new in CodeIgniter 4.7 and how to upgrade.

Frequently asked questions

  • Which CodeIgniter versions are affected by the November 2026 advisories?

    All four advisories list CodeIgniter 4.7.5 and earlier as affected. They are fixed in 4.7.6, released on 1 November 2026.

  • Am I affected by the named binds SQL injection if I only use where() and insert()?

    No. Plain where(), like(), insert() and update() calls were not affected. The issue needs a named bind combined with a value that was already escaped and rendered into the SQL, such as a subquery, a custom where() string built with $db->escape(), or the WHERE binds of deleteBatch().

  • Does CodeIgniter 4.7.6 contain breaking changes?

    Yes, three, all tied to the security fixes: Model::replace() applies field protection, file cache deleteMatching() no longer matches files in subdirectories, and named bind placeholders inside quoted strings, quoted identifiers and comments are left untouched. File name sanitisation also removes every backslash.

  • Why does replace() throw a DataException after the upgrade?

    Because the data passed to it had no field listed in $allowedFields, or only the primary key, after filtering. Add the fields the call needs to $allowedFields, or for a trusted operation call protect(false) before replace() and protect(true) afterwards.

  • Which project files should I merge after updating to 4.7.6?

    The upgrade guide lists no changed config files for 4.7.6. Updating the framework package, or replacing the system directory in a manual installation, is enough.

Sources

  1. Version 4.7.6 change log — CodeIgniter, 2026-11-01
  2. Upgrading from 4.7.5 to 4.7.6 — CodeIgniter, 2026-11-01
  3. CodeIgniter 4.7.6 release — GitHub, 2026-11-01
  4. SQL injection via named bind placeholders (GHSA-25rf-99hr-7pmr) — GitHub Security Advisories, 2026-11-01
  5. Mass assignment protection bypass in Model::replace() (GHSA-jv74-fx4h-m63x) — GitHub Security Advisories, 2026-11-01
  6. Path traversal in file cache pattern deletion (GHSA-9hf2-g3w9-pfmp) — GitHub Security Advisories, 2026-11-01
  7. Path traversal in sanitize_filename() (GHSA-9j59-qcxw-q7qm) — GitHub Security Advisories, 2026-11-01

Written with substantial AI assistance. Facts checked against cited sources. Editorial policy.

New tools, once a week

One short email listing what joined the directory.

The weekly email about new tools and occasional newsletters. Unsubscribe at any time.

Comments

No comments yet. Be the first to join the conversation.

Leave a comment

Every comment is read by a moderator before it appears. Your email address is never published; it is used only to contact you about this comment.

Never published. Used only to contact you about this comment.

Loading the security check…

Comments are moderated before publication.

  • Cloudsoft Zone cover: CodeIgniter 4 validation not working? 9 causes and fixes

    Troubleshooting guideCodeIgniter6 min read

    CodeIgniter 4 validation not working? 9 causes and fixes

    Fix CodeIgniter 4 validation problems fast: wrong input source, lost errors after redirect, permit_empty, strict JSON rules, is_unique placeholders and more.

    By Nilesh Kushvaha

  • Cloudsoft Zone cover: upgrade a Laravel app to PHP 8.6

    TutorialPHP7 min read

    Upgrading a Laravel app to PHP 8.6: compatibility, deprecations and tests

    Laravel 13.44 is the first release that supports PHP 8.6. This plan covers the support matrix, Composer checks, the PHP 8.6 deprecations that show up in Laravel code, the session and trim() changes, PHPStan and Rector settings, a CI matrix and a staged rollout.

    By Nilesh Kushvaha