Skip to content

Commit 17e9fc3

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 12fba3f + 7231622 commit 17e9fc3

9 files changed

Lines changed: 176 additions & 18 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# Changelog
22

3+
## [v4.7.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.7.3) (2026-05-22)
4+
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.7.2...v4.7.3)
5+
6+
### Security
7+
8+
* **Validation**: *Uploaded file extension validation bypass in `ext_in` rule*
9+
The ``ext_in`` file upload validation rule now validates the client filename extension and verifies that it
10+
matches the detected MIME type. Previously, ``ext_in`` only checked the MIME-derived guessed extension, so
11+
a file with a mismatched client extension could pass validation.
12+
13+
See the [GHSA-2gr4-ppc7-7mhx security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-2gr4-ppc7-7mhx) for more information. Credits to @z3moo and @teebow1e for reporting the issue.
14+
15+
### Fixed Bugs
16+
17+
* fix: make Autoloader composer path injectable to fix parallel test race condition by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10082
18+
* fix: store SPL closures in `register()` so `unregister()` can remove them by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10097
19+
* fix: ensure output buffer is closed after use of `command()` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10099
20+
* fix: preserve null values in Validation::getValidated() by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10101
21+
* fix: refactor inconsistent behavior on `CLI::write()` and `CLI::error()` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10106
22+
* fix: ensure calling `env` command with options only would not throw by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10114
23+
* fix: suppress stty stderr leak in `CLI::generateDimensions()` when stdin is not a TTY by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10124
24+
* fix: reset Kint CSP state in worker mode by @memleakd in https://github.com/codeigniter4/CodeIgniter4/pull/10139
25+
* fix: make `Time::createFromTimestamp` locale-independent by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10151
26+
* fix: SQLSRV driver's `decrement()` method by @patel-vansh in https://github.com/codeigniter4/CodeIgniter4/pull/10155
27+
* fix: suppress tput stderr leak when TERM is not present by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10167
28+
* fix: support third-party loggers in toolbar logs collector by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10173
29+
* fix: PostgreSQL Builder's `increment()` and `decrement()` methods not working for numeric columns by @patel-vansh in https://github.com/codeigniter4/CodeIgniter4/pull/10172
30+
* fix: preserve cached table list shape by @memleakd in https://github.com/codeigniter4/CodeIgniter4/pull/10179
31+
* fix: harden regex matching on `key:generate` command by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10183
32+
* fix: restore deep dot-notation traversal in `Language::getLine()` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10189
33+
* fix: make frankenphp-worker.php template idempotent on watcher restart by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10191
34+
* fix: `Entity::normalizeValue()` must handle `UnitEnum` before `toArray()` by @maniaba in https://github.com/codeigniter4/CodeIgniter4/pull/10137
35+
* fix: recognize off zlib output compression value by @memleakd in https://github.com/codeigniter4/CodeIgniter4/pull/10193
36+
* fix: escape `--host` option in `serve` command by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10203
37+
38+
### Refactoring
39+
40+
* refactor: add full testing for `logs:clear` command by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10090
41+
* refactor: add full testing for `debugbar:clear` command by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10093
42+
* refactor: pass `--do-not-cache-result` to prevent shared cache corruption by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/10098
43+
* refactor: add full testing for `cache:clear` command by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10094
44+
* refactor: rename `-h` option of `routes` command as `--handler` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10113
45+
* refactor: further rename `--handler` to `--sort-by-handler` for `routes` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10125
46+
* refactor: UX: `ClearLogs::execute()` error message is misleading after interactive `'n'` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10126
47+
* refactor: simplify `FileLocator::listFiles()` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/10142
48+
* refactor: reduce PHPStan child return type baseline by @memleakd in https://github.com/codeigniter4/CodeIgniter4/pull/10165
49+
* refactor: remove PHPStan callable signature baseline by @memleakd in https://github.com/codeigniter4/CodeIgniter4/pull/10166
50+
351
## [v4.7.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.7.2) (2026-03-24)
452
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.7.1...v4.7.2)
553

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"boundwize/structarmed": "0.6.8",
20+
"boundwize/structarmed": "0.6.15",
2121
"codeigniter/phpstan-codeigniter": "^1.5",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",
@@ -29,7 +29,7 @@
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.4.3",
32+
"rector/rector": "2.4.4",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

‎phpdoc.dist.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<output>api/build/</output>
1111
<cache>api/cache/</cache>
1212
</paths>
13-
<version number="4.7.2">
13+
<version number="4.7.3">
1414
<api format="php">
1515
<source dsn=".">
1616
<path>system</path>

‎system/Validation/StrictRules/FileRules.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,14 @@ public function ext_in(?string $blank, string $params): bool
208208
return true;
209209
}
210210

211-
if (! in_array($file->guessExtension(), $params, true)) {
211+
// Check the real filename extension, not only the guessed extension.
212+
$clientExtension = strtolower($file->getClientExtension());
213+
214+
if ($clientExtension === '' || ! in_array($clientExtension, $params, true)) {
215+
return false;
216+
}
217+
218+
if ($file->guessExtension() !== $clientExtension) {
212219
return false;
213220
}
214221
}

‎tests/system/Validation/StrictRules/FileRulesTest.php‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@ public function testExtensionOk(): void
338338
$this->assertTrue($this->validation->run([]));
339339
}
340340

341+
public function testExtensionOkWithMatchingClientExtensionAndMimeType(): void
342+
{
343+
$payload = $this->createGifPayload();
344+
345+
try {
346+
$this->setUploadedAvatar($payload, 'my-avatar.gif');
347+
348+
$this->validation->setRules(['avatar' => 'ext_in[avatar,gif]']);
349+
$this->assertTrue($this->validation->run([]));
350+
} finally {
351+
unlink($payload);
352+
}
353+
}
354+
341355
public function testExtensionNotOk(): void
342356
{
343357
$this->validation->setRules(['avatar' => 'ext_in[avatar,xls,doc,ppt]']);
@@ -349,4 +363,72 @@ public function testExtensionImpossible(): void
349363
$this->validation->setRules(['avatar' => 'ext_in[unknown,xls,doc,ppt]']);
350364
$this->assertFalse($this->validation->run([]));
351365
}
366+
367+
public function testExtensionFailsForMismatchedClientExtension(): void
368+
{
369+
$payload = $this->createGifPayload();
370+
371+
try {
372+
$this->setUploadedAvatar($payload, 'shell.php');
373+
374+
$this->validation->setRules(['avatar' => 'ext_in[avatar,gif]']);
375+
$this->assertFalse($this->validation->run([]));
376+
} finally {
377+
unlink($payload);
378+
}
379+
}
380+
381+
public function testExtensionFailsForAllowedButMimeIncompatibleClientExtension(): void
382+
{
383+
$payload = $this->createGifPayload();
384+
385+
try {
386+
$this->setUploadedAvatar($payload, 'my-avatar.jpg');
387+
388+
$this->validation->setRules(['avatar' => 'ext_in[avatar,jpg,gif]']);
389+
$this->assertFalse($this->validation->run([]));
390+
} finally {
391+
unlink($payload);
392+
}
393+
}
394+
395+
public function testExtensionFailsForExtensionlessClientFilename(): void
396+
{
397+
$payload = $this->createGifPayload();
398+
399+
try {
400+
$this->setUploadedAvatar($payload, 'my-avatar');
401+
402+
$this->validation->setRules(['avatar' => 'ext_in[avatar,gif]']);
403+
$this->assertFalse($this->validation->run([]));
404+
} finally {
405+
unlink($payload);
406+
}
407+
}
408+
409+
private function createGifPayload(): string
410+
{
411+
$payload = tempnam(sys_get_temp_dir(), 'ci4-upload-poc-');
412+
$this->assertIsString($payload);
413+
414+
$gif = base64_decode('R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==', true);
415+
$this->assertIsString($gif);
416+
417+
file_put_contents($payload, $gif);
418+
419+
return $payload;
420+
}
421+
422+
private function setUploadedAvatar(string $payload, string $name): void
423+
{
424+
service('superglobals')->setFilesArray([
425+
'avatar' => [
426+
'tmp_name' => $payload,
427+
'name' => $name,
428+
'size' => filesize($payload),
429+
'type' => 'image/gif',
430+
'error' => UPLOAD_ERR_OK,
431+
],
432+
]);
433+
}
352434
}

‎user_guide_src/source/changelogs/v4.7.3.rst‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Version 4.7.3
33
#############
44

5-
Release Date: Unreleased
5+
Release Date: May 22, 2026
66

77
**4.7.3 release of CodeIgniter4**
88

@@ -11,9 +11,16 @@ Release Date: Unreleased
1111
:depth: 3
1212

1313
********
14-
BREAKING
14+
SECURITY
1515
********
1616

17+
- **Validation:** The ``ext_in`` file upload validation rule now validates the
18+
client filename extension and verifies that it matches the detected MIME type.
19+
Previously, ``ext_in`` only checked the MIME-derived guessed extension, so a
20+
file with a mismatched client extension could pass validation.
21+
See the `Security advisory GHSA-2gr4-ppc7-7mhx <https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-2gr4-ppc7-7mhx>`_
22+
for more information.
23+
1724
***************
1825
Message Changes
1926
***************
@@ -28,10 +35,6 @@ Changes
2835
The old ``-h`` option will continue to work until v4.8.0, at which point it will be removed and repurposed as a shortcut for ``--help``.
2936
A warning message is displayed when using the old ``-h`` option to encourage users to switch to the new ``--sort-by-handler`` option.
3037

31-
************
32-
Deprecations
33-
************
34-
3538
**********
3639
Bugs Fixed
3740
**********

‎user_guide_src/source/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
version = '4.7'
2727

2828
# The full version, including alpha/beta/rc tags.
29-
release = '4.7.2'
29+
release = '4.7.3'
3030

3131
# -- General configuration ---------------------------------------------------
3232

‎user_guide_src/source/installation/upgrade_473.rst‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,19 @@ upgrading. The easiest way is to re-run the install command:
3030
Breaking Changes
3131
****************
3232

33-
*********************
34-
Breaking Enhancements
35-
*********************
33+
File Validation
34+
===============
35+
36+
The ``ext_in`` file upload validation rule now checks the client filename
37+
extension and verifies that the detected MIME type is associated with that
38+
extension. Previously, ``ext_in`` only checked the MIME-derived guessed
39+
extension.
40+
41+
This means files with no client filename extension, or files whose client
42+
filename extension does not match the detected MIME type, now fail ``ext_in``
43+
validation. If your application intentionally accepts such files, remove
44+
``ext_in`` from those validation rules and use a custom validation rule that
45+
matches your application's requirements.
3646

3747
*************
3848
Project Files
@@ -54,12 +64,18 @@ and it is recommended that you merge the updated versions with your application:
5464
Config
5565
------
5666

57-
- @TODO
67+
- app/Config/Database.php
68+
- app/Config/Events.php
69+
- app/Config/Routes.php
70+
- app/Config/View.php
5871

5972
All Changes
6073
===========
6174

6275
This is a list of all files in the **project space** that received changes;
6376
many will be simple comments or formatting that have no effect on the runtime:
6477

65-
- @TODO
78+
- app/Config/Database.php
79+
- app/Config/Events.php
80+
- app/Config/Routes.php
81+
- app/Config/View.php

‎user_guide_src/source/libraries/validation.rst‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,8 +1201,10 @@ min_dims Yes Fails if the minimum width and height of an
12011201
v4.6.0.)
12021202
mime_in Yes Fails if the file's mime type is not one ``mime_in[field_name,image/png,image/jpeg]``
12031203
listed in the parameters.
1204-
ext_in Yes Fails if the file's extension is not one ``ext_in[field_name,png,jpg,gif]``
1205-
listed in the parameters.
1204+
ext_in Yes Fails if the client filename's extension is ``ext_in[field_name,png,jpg,gif]``
1205+
not one listed in the parameters, or if the
1206+
detected MIME type does not match the MIME
1207+
types associated with the extension.
12061208
is_image Yes Fails if the file cannot be determined to be ``is_image[field_name]``
12071209
an image based on the mime type.
12081210
======================= ========== ============================================= ===================================================

0 commit comments

Comments
 (0)