MediumGHSA-4v37-24gm-h554BIT-codeigniter-2022-24712CVE-2022-24712

Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability in CodeIgniter4

Published 1 Mar 2022 · Updated 6 Dec 2023

Affected package

Affected
<4.1.9
Fixed in
4.1.9
Update to the fixed version for your release line, for example:composer require codeigniter4/framework:^4.1.9

Details

Impact

This vulnerability might allow remote attackers to bypass the CodeIgniter4 CSRF protection mechanism.

Patches

Upgrade to v4.1.9 or later.

Workarounds

These are workarounds for this vulnerability, but you will still need to code as these after upgrading to v4.1.9. Otherwise, the CSRF protection may be bypassed.

When Auto-Routing is Enabled

1. Check the request method in the controller method before processing.

E.g.:

        if (strtolower($this->request->getMethod()) !== 'post') {
            return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
        }

When Auto-Routing is Disabled

Do one of the following: 1. Do not use $routes->add(), and use HTTP verbs in routes. 2. Check the request method in the controller method before processing.

E.g.:

        if (strtolower($this->request->getMethod()) !== 'post') {
            return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
        }

References

For more information

If you have any questions or comments about this advisory:

Is GHSA-4v37-24gm-h554 in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected codeigniter4/framework, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.