Skip to content

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

Moderate
MGatner published GHSA-4v37-24gm-h554 Feb 26, 2022

Package

composer codeigniter4/framework (Composer)

Affected versions

< 4.1.9

Patched versions

4.1.9

Description

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:

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:L

CVE ID

CVE-2022-24712

Weaknesses