Skip to content

Commit 9c0c695

Browse files
authored
Merge pull request #6354 from codeigniter4/develop
4.2.3 Ready code
2 parents 26b247d + d77883e commit 9c0c695

File tree

14 files changed

+88
-18
lines changed

14 files changed

+88
-18
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v4.2.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.3) (2022-08-06)
4+
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.2...v4.2.3)
5+
6+
* SECURITY: Improve CSRF protection (for Shield CSRF security fix)
7+
38
## [v4.2.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.2) (2022-08-05)
49
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.1...v4.2.2)
510

admin/RELEASE.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Documentation guide based on the releases of `4.0.5` and `4.1.0` on January 31, 2021.
44
>
5-
> Updated for `4.1.6` on December 24, 2021.
5+
> Updated for `4.2.3` on August 6, 2022.
66
>
77
> -MGatner
88
@@ -29,8 +29,9 @@ git clone git@github.com:codeigniter4/CodeIgniter4.git
2929
git clone git@github.com:codeigniter4/userguide.git
3030
```
3131
* Vet the **admin/** folders for any removed hidden files (Action deploy scripts *do not remove these*)
32+
* Merge any Security Advisory PRs in private forks
3233

33-
## CodeIgniter4
34+
## Process
3435

3536
> Note: Most changes that need noting in the User Guide and docs should have been included
3637
> with their PR, so this process assumes you will not be generating much new content.
@@ -75,6 +76,7 @@ composer create-project codeigniter4/appstarter release-test
7576
cd release-test
7677
composer test && composer info codeigniter4/framework
7778
```
79+
* publish any Security Advisories that were resolved from private forks
7880

7981
## User Guide
8082

system/CodeIgniter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CodeIgniter
4747
/**
4848
* The current version of CodeIgniter Framework
4949
*/
50-
public const CI_VERSION = '4.2.2';
50+
public const CI_VERSION = '4.2.3';
5151

5252
/**
5353
* App startup time.

system/Security/Security.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ private function restoreHash(): void
528528
}
529529

530530
/**
531-
* Generates (Regenerate) the CSRF Hash.
531+
* Generates (Regenerates) the CSRF Hash.
532532
*/
533-
protected function generateHash(): string
533+
public function generateHash(): string
534534
{
535535
$this->hash = bin2hex(random_bytes(static::CSRF_HASH_BYTES));
536536

tests/system/Security/SecurityTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,32 @@ public function testRegenerateWithFalseSecurityRegenerateProperty()
243243
$this->assertSame($oldHash, $newHash);
244244
}
245245

246+
public function testRegenerateWithFalseSecurityRegeneratePropertyManually()
247+
{
248+
$_SERVER['REQUEST_METHOD'] = 'POST';
249+
$_POST['csrf_test_name'] = '8b9218a55906f9dcc1dc263dce7f005a';
250+
$_COOKIE['csrf_cookie_name'] = '8b9218a55906f9dcc1dc263dce7f005a';
251+
252+
$config = new SecurityConfig();
253+
$config->regenerate = false;
254+
Factories::injectMock('config', 'Security', $config);
255+
256+
$security = new MockSecurity(new MockAppConfig());
257+
$request = new IncomingRequest(
258+
new MockAppConfig(),
259+
new URI('http://badurl.com'),
260+
null,
261+
new UserAgent()
262+
);
263+
264+
$oldHash = $security->getHash();
265+
$security->verify($request);
266+
$security->generateHash();
267+
$newHash = $security->getHash();
268+
269+
$this->assertNotSame($oldHash, $newHash);
270+
}
271+
246272
public function testRegenerateWithTrueSecurityRegenerateProperty()
247273
{
248274
$_SERVER['REQUEST_METHOD'] = 'POST';

user_guide_src/source/changelogs/index.rst

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

15+
v4.2.4
1516
v4.2.3
1617
v4.2.2
1718
v4.2.1

user_guide_src/source/changelogs/v4.2.2.rst

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ BREAKING
1818
- A bug that caused pages to be cached before after filters were executed when using page caching has been fixed. Adding response headers or changing the response body in after filters now caches them correctly.
1919
- Due to a bug fix, now :php:func:`random_string` with the first parameter ``'crypto'`` throws ``InvalidArgumentException`` if the second parameter ``$len`` is an odd number.
2020

21-
Enhancements
22-
************
23-
24-
none.
25-
2621
Changes
2722
*******
2823

user_guide_src/source/changelogs/v4.2.3.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Version 4.2.3
22
#############
33

4-
Release Date: Unreleased
4+
Release Date: August 6, 2022
55

66
**4.2.3 release of CodeIgniter4**
77

@@ -17,7 +17,7 @@ none.
1717
Enhancements
1818
************
1919

20-
none.
20+
- Now ``Security::generateHash()`` is public, and can be used to regenerate CSRF token manually when ``Config\Security::$regenerate`` is false.
2121

2222
Changes
2323
*******
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Version 4.2.4
2+
#############
3+
4+
Release Date: Unreleased
5+
6+
**4.2.4 release of CodeIgniter4**
7+
8+
.. contents::
9+
:local:
10+
:depth: 2
11+
12+
BREAKING
13+
********
14+
15+
none.
16+
17+
Enhancements
18+
************
19+
20+
none.
21+
22+
Changes
23+
*******
24+
25+
none.
26+
27+
Deprecations
28+
************
29+
30+
none.
31+
32+
Bugs Fixed
33+
**********
34+
35+
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

user_guide_src/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
version = '4.2'
2525

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

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

user_guide_src/source/installation/upgrade_422.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ Please refer to the upgrade instructions corresponding to your installation meth
1212
:local:
1313
:depth: 2
1414

15-
Mandatory File Changes
16-
**********************
17-
18-
1915
Breaking Changes
2016
****************
2117

@@ -55,6 +51,8 @@ Content Changes
5551

5652
* app/Views/errors/html/error_404.php
5753
* app/Views/welcome_message.php
54+
* public/index.php
55+
* spark
5856

5957
All Changes
6058
===========
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#############################
2+
Upgrading from 4.2.2 to 4.2.3
3+
#############################
4+
5+
Version ``4.2.3`` is an internal change for security measures and requires no intervention in projects.

user_guide_src/source/libraries/security.rst

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ may alter this behavior by editing the following config parameter value in
106106

107107
.. literalinclude:: security/004.php
108108

109+
.. note:: Since v4.2.3, you can regenerate CSRF token manually with the
110+
``Security::generateHash()`` method.
111+
109112
Redirection on Failure
110113
----------------------
111114

user_guide_src/source/libraries/sessions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ necessary with our new implementation. However, it may happen that your
369369
application relied on these values, so here are alternative methods of
370370
accessing them:
371371

372-
- session_id: ``session_id()``
372+
- session_id: ``$session->session_id`` or ``session_id()`` (PHP’s built-in function)
373373
- ip_address: ``$_SERVER['REMOTE_ADDR']``
374374
- user_agent: ``$_SERVER['HTTP_USER_AGENT']`` (unused by sessions)
375375
- last_activity: Depends on the storage, no straightforward way. Sorry!

0 commit comments

Comments
 (0)