GitHub Advisoryadvisory · Packagist
GHSA-4v37-24gm-h554 Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability in CodeIgniter4
MEDIUM
Official page ↗
- Aliases
- CVE-2022-24712
- Ecosystem
- Packagist
- Packages
- codeigniter4/framework
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:L
- Weaknesses
- CWE-352
- Reviewed
- 2022-03-01
Affected packages
• Packagist codeigniter4/framework: < 4.1.9 → fixed in 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.:
```php
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.:
```php
if (strtolower($this->request->getMethod()) !== 'post') {
return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
}
```
References
• CodeIgniter4 CSRF protection
For more information
If you have any questions or comments about this advisory:
• Open an issue in codeigniter4/CodeIgniter4
• Email us at SECURITY.md
Related
Alias · CVE (1)
- CVE-2022-24712 CodeIgniter4 is the 4.x branch of CodeIgniter, a PHP full-stack web framework. vulnerability
Weakness · CWE (1)
- CWE-352 Cross-Site Request Forgery weakness