GHSA-4v37-24gm-h554medium6.3
Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability in CodeIgniter4
Impact
This vulnerability might allow remote attackers to bypass the CodeIgniter4 CSRF protection mechanism.
Source excerpt · OSVAffected packages
Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.
codeigniter4/framework Packagist
| Affected range | Recorded fix |
|---|---|
| Earlier releases before 4.1.9Ecosystem versions | 4.1.9 |
Version evidence: OSV · GHSA-4v37-24gm-h554
View original version evidence (27 explicit versions)
Original source 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
- 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:
- Do not use
$routes->add(), and use HTTP verbs in routes. - 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:
- Open an issue in codeigniter4/CodeIgniter4
- Email us at SECURITY.md