Skip to content

Commit 83fc5b2

Browse files
committed
Merge remote-tracking branch 'upstream/master' into develop
2 parents 196d759 + 202f41a commit 83fc5b2

File tree

8 files changed

+96
-8
lines changed

8 files changed

+96
-8
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)

phpstan-baseline.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ parameters:
110110
count: 1
111111
path: system/CodeIgniter.php
112112

113-
-
114-
message: "#^Dead catch \\- CodeIgniter\\\\Exceptions\\\\PageNotFoundException is never thrown in the try block\\.$#"
115-
count: 1
116-
path: system/CodeIgniter.php
117-
118113
-
119114
message: "#^Property Config\\\\App\\:\\:\\$appTimezone \\(string\\) on left side of \\?\\? is not nullable\\.$#"
120115
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.4';
5151

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

319319
$this->spoofRequestMethod();
320320

321+
if ($this->request instanceof IncomingRequest && $this->request->getMethod() === 'cli') {
322+
$this->response->setStatusCode(405)->setBody('Method Not Allowed');
323+
324+
return $this->sendResponse();
325+
}
326+
321327
Events::trigger('pre_system');
322328

323329
// Check for a cached page. Execution will stop
@@ -400,6 +406,7 @@ private function isWeb(): bool
400406
/**
401407
* Handles the main request logic and fires the controller.
402408
*
409+
* @throws PageNotFoundException
403410
* @throws RedirectException
404411
*
405412
* @return mixed|RequestInterface|ResponseInterface
@@ -1046,7 +1053,10 @@ public function spoofRequestMethod()
10461053
return;
10471054
}
10481055

1049-
$this->request = $this->request->setMethod($method);
1056+
// Only allows PUT, PATCH, DELETE
1057+
if (in_array(strtoupper($method), ['PUT', 'PATCH', 'DELETE'], true)) {
1058+
$this->request = $this->request->setMethod($method);
1059+
}
10501060
}
10511061

10521062
/**

tests/system/CodeIgniterTest.php

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

442442
$this->assertStringContainsString('Welcome to CodeIgniter', $output);
443443
}
444+
445+
public function testRunCLIRoute()
446+
{
447+
$_SERVER['argv'] = ['index.php', 'cli'];
448+
$_SERVER['argc'] = 2;
449+
450+
$_SERVER['REQUEST_URI'] = '/cli';
451+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
452+
$_SERVER['REQUEST_METHOD'] = 'CLI';
453+
454+
$routes = Services::routes();
455+
$routes->cli('cli', '\Tests\Support\Controllers\Popcorn::index');
456+
457+
ob_start();
458+
$this->codeigniter->useSafeOutput(true)->run();
459+
$output = ob_get_clean();
460+
461+
$this->assertStringContainsString('Method Not Allowed', $output);
462+
}
463+
464+
public function testSpoofRequestMethodCanUsePUT()
465+
{
466+
$_SERVER['argv'] = ['index.php'];
467+
$_SERVER['argc'] = 1;
468+
469+
$_SERVER['REQUEST_URI'] = '/';
470+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
471+
$_SERVER['REQUEST_METHOD'] = 'POST';
472+
473+
$_POST['_method'] = 'PUT';
474+
475+
ob_start();
476+
$this->codeigniter->useSafeOutput(true)->run();
477+
ob_get_clean();
478+
479+
$this->assertSame('put', Services::request()->getMethod());
480+
}
481+
482+
public function testSpoofRequestMethodCannotUseGET()
483+
{
484+
$_SERVER['argv'] = ['index.php'];
485+
$_SERVER['argc'] = 1;
486+
487+
$_SERVER['REQUEST_URI'] = '/';
488+
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
489+
$_SERVER['REQUEST_METHOD'] = 'POST';
490+
491+
$_POST['_method'] = 'GET';
492+
493+
ob_start();
494+
$this->codeigniter->useSafeOutput(true)->run();
495+
ob_get_clean();
496+
497+
$this->assertSame('post', Services::request()->getMethod());
498+
}
444499
}

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
@@ -13,6 +13,7 @@ See all the changes.
1313
:titlesonly:
1414

1515
v4.2.0
16+
v4.1.9
1617
v4.1.8
1718
v4.1.7
1819
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

0 commit comments

Comments
 (0)