Skip to content

Commit 202f41a

Browse files
authored
Merge pull request from GHSA-xjp4-6w75-qrj7
Hotfix 4.1.9
2 parents e149231 + 6b35f03 commit 202f41a

File tree

10 files changed

+100
-11
lines changed

10 files changed

+100
-11
lines changed

CHANGELOG.md

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

3+
## [v4.1.9](https://github.com/codeigniter4/CodeIgniter4/tree/v4.1.9) (2022-02-25)
4+
5+
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.1.8...v4.1.9)
6+
7+
**SECURITY**
8+
9+
* *Remote CLI Command Execution Vulnerability* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-xjp4-6w75-qrj7) for more information.
10+
* *Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-4v37-24gm-h554) for more information.
11+
312
## [v4.1.8](https://github.com/codeigniter4/CodeIgniter4/tree/v4.1.8) (2022-01-24)
413

514
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.1.7...v4.1.8)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"psr/log": "^1.1"
1616
},
1717
"require-dev": {
18-
"codeigniter/coding-standard": "^1.1",
18+
"codeigniter/coding-standard": "1.2.*",
1919
"fakerphp/faker": "^1.9",
20-
"friendsofphp/php-cs-fixer": "^3.1",
20+
"friendsofphp/php-cs-fixer": "3.2.*",
2121
"mikey179/vfsstream": "^1.6",
2222
"nexusphp/cs-config": "^3.3",
2323
"nexusphp/tachycardia": "^1.0",
24-
"phpstan/phpstan": "^1.0",
24+
"phpstan/phpstan": "1.4.3",
2525
"phpunit/phpunit": "^9.1",
2626
"predis/predis": "^1.1",
2727
"rector/rector": "0.12.10"

phpstan-baseline.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ parameters:
115115
count: 1
116116
path: system/CodeIgniter.php
117117

118-
-
119-
message: "#^Dead catch \\- CodeIgniter\\\\Exceptions\\\\PageNotFoundException is never thrown in the try block\\.$#"
120-
count: 1
121-
path: system/CodeIgniter.php
122-
123118
-
124119
message: "#^Property Config\\\\App\\:\\:\\$appTimezone \\(string\\) on left side of \\?\\? is not nullable\\.$#"
125120
count: 1

system/CodeIgniter.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CodeIgniter
4545
/**
4646
* The current version of CodeIgniter Framework
4747
*/
48-
public const CI_VERSION = '4.1.8';
48+
public const CI_VERSION = '4.1.9';
4949

5050
private const MIN_PHP_VERSION = '7.3';
5151

@@ -299,6 +299,12 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
299299

300300
$this->spoofRequestMethod();
301301

302+
if ($this->request instanceof IncomingRequest && $this->request->getMethod() === 'cli') {
303+
$this->response->setStatusCode(405)->setBody('Method Not Allowed');
304+
305+
return $this->sendResponse();
306+
}
307+
302308
Events::trigger('pre_system');
303309

304310
// Check for a cached page. Execution will stop
@@ -352,6 +358,7 @@ public function useSafeOutput(bool $safe = true)
352358
/**
353359
* Handles the main request logic and fires the controller.
354360
*
361+
* @throws PageNotFoundException
355362
* @throws RedirectException
356363
*
357364
* @return mixed|RequestInterface|ResponseInterface
@@ -976,7 +983,10 @@ public function spoofRequestMethod()
976983
return;
977984
}
978985

979-
$this->request = $this->request->setMethod($method);
986+
// Only allows PUT, PATCH, DELETE
987+
if (in_array(strtoupper($method), ['PUT', 'PATCH', 'DELETE'], true)) {
988+
$this->request = $this->request->setMethod($method);
989+
}
980990
}
981991

982992
/**

tests/system/CodeIgniterTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,59 @@ public function testRunDefaultRoute()
425425

426426
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
427427
}
428+
429+
public function testRunCLIRoute()
430+
{
431+
$_SERVER['argv'] = ['index.php', 'cli'];
432+
$_SERVER['argc'] = 2;
433+
434+
$_SERVER['REQUEST_URI'] = '/cli';
435+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
436+
$_SERVER['REQUEST_METHOD'] = 'CLI';
437+
438+
$routes = Services::routes();
439+
$routes->cli('cli', '\Tests\Support\Controllers\Popcorn::index');
440+
441+
ob_start();
442+
$this->codeigniter->useSafeOutput(true)->run();
443+
$output = ob_get_clean();
444+
445+
$this->assertStringContainsString('Method Not Allowed', $output);
446+
}
447+
448+
public function testSpoofRequestMethodCanUsePUT()
449+
{
450+
$_SERVER['argv'] = ['index.php'];
451+
$_SERVER['argc'] = 1;
452+
453+
$_SERVER['REQUEST_URI'] = '/';
454+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
455+
$_SERVER['REQUEST_METHOD'] = 'POST';
456+
457+
$_POST['_method'] = 'PUT';
458+
459+
ob_start();
460+
$this->codeigniter->useSafeOutput(true)->run();
461+
ob_get_clean();
462+
463+
$this->assertSame('put', Services::request()->getMethod());
464+
}
465+
466+
public function testSpoofRequestMethodCannotUseGET()
467+
{
468+
$_SERVER['argv'] = ['index.php'];
469+
$_SERVER['argc'] = 1;
470+
471+
$_SERVER['REQUEST_URI'] = '/';
472+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
473+
$_SERVER['REQUEST_METHOD'] = 'POST';
474+
475+
$_POST['_method'] = 'GET';
476+
477+
ob_start();
478+
$this->codeigniter->useSafeOutput(true)->run();
479+
ob_get_clean();
480+
481+
$this->assertSame('post', Services::request()->getMethod());
482+
}
428483
}

tests/system/Commands/CommandTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ final class CommandTest extends CIUnitTestCase
2727

2828
protected function setUp(): void
2929
{
30+
$this->resetServices();
31+
3032
parent::setUp();
3133

3234
CITestStreamFilter::$buffer = '';

user_guide_src/source/changelogs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ See all the changes.
1212
.. toctree::
1313
:titlesonly:
1414

15+
v4.1.9
1516
v4.1.8
1617
v4.1.7
1718
v4.1.6
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Version 4.1.9
2+
#############
3+
4+
Release Date: February 25, 2022
5+
6+
**4.1.9 release of CodeIgniter4**
7+
8+
.. contents::
9+
:local:
10+
:depth: 2
11+
12+
SECURITY
13+
********
14+
15+
- *Remote CLI Command Execution Vulnerability* was fixed. See the `Security advisory GHSA-xjp4-6w75-qrj7 <https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-xjp4-6w75-qrj7>`_ for more information.
16+
- *Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability* was fixed. See the `Security advisory GHSA-4v37-24gm-h554 <https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-4v37-24gm-h554>`_ for more information.

user_guide_src/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
version = '4.1'
2525

2626
# The full version, including alpha/beta/rc tags.
27-
release = '4.1.8'
27+
release = '4.1.9'
2828

2929
# -- General configuration ---------------------------------------------------
3030

user_guide_src/source/installation/upgrading.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ upgrading from.
88
.. toctree::
99
:titlesonly:
1010

11+
Upgrading from 4.1.7 to 4.1.8 <upgrade_418>
1112
Upgrading from 4.1.6 to 4.1.7 <upgrade_417>
1213
Upgrading from 4.1.5 to 4.1.6 <upgrade_416>
1314
Upgrading from 4.1.4 to 4.1.5 <upgrade_415>

0 commit comments

Comments
 (0)