### 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](https://codeigniter4.github.io/userguide/incoming/routing.html#using-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](https://codeigniter4.github.io/userguide/libraries/security.html#cross-site-request-forgery-csrf)
### For more information
If you have any questions or comments about this advisory:
* Open an issue in [codeigniter4/CodeIgniter4](https://github.com/codeigniter4/CodeIgniter4/issues)
* Email us at [SECURITY.md](https://github.com/codeigniter4/CodeIgniter4/blob/develop/SECURITY.md)
{"id": "OSV:GHSA-4V37-24GM-H554", "vendorId": null, "type": "osv", "bulletinFamily": "software", "title": "Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability in CodeIgniter4", "description": "### Impact\nThis vulnerability might allow remote attackers to bypass the CodeIgniter4 CSRF protection mechanism. \n\n### Patches\nUpgrade to v4.1.9 or later.\n\n### Workarounds\nThese are workarounds for this vulnerability, but **you will still need to code as these after upgrading to v4.1.9**.\nOtherwise, the CSRF protection may be bypassed.\n\n#### When Auto-Routing is Enabled\n1. Check the request method in the controller method before processing.\n\nE.g.:\n```php\n if (strtolower($this->request->getMethod()) !== 'post') {\n return $this->response->setStatusCode(405)->setBody('Method Not Allowed');\n }\n```\n\n#### When Auto-Routing is Disabled\nDo one of the following:\n1. Do not use `$routes->add()`, and [use HTTP verbs in routes](https://codeigniter4.github.io/userguide/incoming/routing.html#using-http-verbs-in-routes).\n2. Check the request method in the controller method before processing.\n\nE.g.:\n```php\n if (strtolower($this->request->getMethod()) !== 'post') {\n return $this->response->setStatusCode(405)->setBody('Method Not Allowed');\n }\n```\n\n### References\n- [CodeIgniter4 CSRF protection](https://codeigniter4.github.io/userguide/libraries/security.html#cross-site-request-forgery-csrf)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [codeigniter4/CodeIgniter4](https://github.com/codeigniter4/CodeIgniter4/issues)\n* Email us at [SECURITY.md](https://github.com/codeigniter4/CodeIgniter4/blob/develop/SECURITY.md)\n", "published": "2022-03-01T21:47:28", "modified": "2022-03-01T21:47:28", "cvss": {"score": 6.8, "vector": "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, "cvss2": {"cvssV2": {"version": "2.0", "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "accessVector": "NETWORK", "accessComplexity": "MEDIUM", "authentication": "NONE", "confidentialityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "availabilityImpact": "PARTIAL", "baseScore": 6.8}, "severity": "MEDIUM", "exploitabilityScore": 8.6, "impactScore": 6.4, "acInsufInfo": false, "obtainAllPrivilege": false, "obtainUserPrivilege": false, "obtainOtherPrivilege": false, "userInteractionRequired": true}, "cvss3": {"cvssV3": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH", "baseScore": 8.8, "baseSeverity": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 5.9}, "href": "https://osv.dev/vulnerability/GHSA-4v37-24gm-h554", "reporter": "Google", "references": ["https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-4v37-24gm-h554", "https://nvd.nist.gov/vuln/detail/CVE-2022-24712", "https://github.com/codeigniter4/CodeIgniter4/blob/7dc2ece32401ebde67122f7d2460efcaee7c352e/user_guide_src/source/changelogs/v4.1.9.rst"], "cvelist": ["CVE-2022-24712"], "immutableFields": [], "lastseen": "2022-06-07T05:28:33", "viewCount": 3, "enchantments": {"backreferences": {"references": [{"type": "cve", "idList": ["CVE-2022-24712"]}, {"type": "github", "idList": ["GHSA-4V37-24GM-H554"]}]}, "score": {"value": 6.3, "vector": "NONE"}, "vulnersScore": 6.3}, "_state": {"dependencies": 0}, "_internal": {}, "affectedSoftware": []}
{"github": [{"lastseen": "2022-03-08T20:28:23", "description": "### Impact\r\nThis vulnerability might allow remote attackers to bypass the CodeIgniter4 CSRF protection mechanism. \r\n\r\n### Patches\r\nUpgrade to v4.1.9 or later.\r\n\r\n### Workarounds\r\nThese are workarounds for this vulnerability, but **you will still need to code as these after upgrading to v4.1.9**.\r\nOtherwise, the CSRF protection may be bypassed.\r\n\r\n#### When Auto-Routing is Enabled\r\n1. Check the request method in the controller method before processing.\r\n\r\nE.g.:\r\n```php\r\n if (strtolower($this->request->getMethod()) !== 'post') {\r\n return $this->response->setStatusCode(405)->setBody('Method Not Allowed');\r\n }\r\n```\r\n\r\n#### When Auto-Routing is Disabled\r\nDo one of the following:\r\n1. Do not use `$routes->add()`, and [use HTTP verbs in routes](https://codeigniter4.github.io/userguide/incoming/routing.html#using-http-verbs-in-routes).\r\n2. Check the request method in the controller method before processing.\r\n\r\nE.g.:\r\n```php\r\n if (strtolower($this->request->getMethod()) !== 'post') {\r\n return $this->response->setStatusCode(405)->setBody('Method Not Allowed');\r\n }\r\n```\r\n\r\n### References\r\n- [CodeIgniter4 CSRF protection](https://codeigniter4.github.io/userguide/libraries/security.html#cross-site-request-forgery-csrf)\r\n\r\n### For more information\r\nIf you have any questions or comments about this advisory:\r\n* Open an issue in [codeigniter4/CodeIgniter4](https://github.com/codeigniter4/CodeIgniter4/issues)\r\n* Email us at [SECURITY.md](https://github.com/codeigniter4/CodeIgniter4/blob/develop/SECURITY.md)\r\n", "cvss3": {"exploitabilityScore": 2.8, "cvssV3": {"baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "attackComplexity": "LOW", "scope": "UNCHANGED", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "baseScore": 8.8, "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "version": "3.1", "userInteraction": "REQUIRED"}, "impactScore": 5.9}, "published": "2022-03-01T21:47:28", "type": "github", "title": "Cross-Site Request Forgery (CSRF) Protection Bypass Vulnerability in CodeIgniter4", "bulletinFamily": "software", "cvss2": {"severity": "MEDIUM", "exploitabilityScore": 8.6, "obtainAllPrivilege": false, "userInteractionRequired": true, "obtainOtherPrivilege": false, "cvssV2": {"accessComplexity": "MEDIUM", "confidentialityImpact": "PARTIAL", "availabilityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "baseScore": 6.8, "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0", "accessVector": "NETWORK", "authentication": "NONE"}, "impactScore": 6.4, "acInsufInfo": false, "obtainUserPrivilege": false}, "cvelist": ["CVE-2022-24712"], "modified": "2022-03-01T22:50:08", "id": "GHSA-4V37-24GM-H554", "href": "https://github.com/advisories/GHSA-4v37-24gm-h554", "cvss": {"score": 6.8, "vector": "AV:N/AC:M/Au:N/C:P/I:P/A:P"}}], "veracode": [{"lastseen": "2022-05-12T00:11:09", "description": "codeigniter4/framework is vulnerable to cross-site request forgery. When auto-routing is enabled, the library checks the request method in the controller method before processing. When auto-routing is disabled, avoid using `$routes->add()` and instead use HTTP verbs in routes, allowing an attacker to bypass the CSRF protection mechanism.\n", "cvss3": {"exploitabilityScore": 2.8, "cvssV3": {"baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "attackComplexity": "LOW", "scope": "UNCHANGED", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "baseScore": 8.8, "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "version": "3.1", "userInteraction": "REQUIRED"}, "impactScore": 5.9}, "published": "2022-03-01T07:34:39", "type": "veracode", "title": "Cross-Site Request Forgery (CSRF)", "bulletinFamily": "software", "cvss2": {"severity": "MEDIUM", "exploitabilityScore": 8.6, "obtainAllPrivilege": false, "userInteractionRequired": true, "obtainOtherPrivilege": false, "cvssV2": {"accessComplexity": "MEDIUM", "confidentialityImpact": "PARTIAL", "availabilityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "baseScore": 6.8, "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0", "accessVector": "NETWORK", "authentication": "NONE"}, "impactScore": 6.4, "acInsufInfo": false, "obtainUserPrivilege": false}, "cvelist": ["CVE-2022-24712"], "modified": "2022-03-08T19:12:00", "id": "VERACODE:34471", "href": "https://sca.analysiscenter.veracode.com/vulnerability-database/security/1/1/sid-34471/summary", "cvss": {"score": 6.8, "vector": "AV:N/AC:M/Au:N/C:P/I:P/A:P"}}], "cve": [{"lastseen": "2022-03-23T10:23:10", "description": "CodeIgniter4 is the 4.x branch of CodeIgniter, a PHP full-stack web framework. A vulnerability in versions prior to 4.1.9 might allow remote attackers to bypass the CodeIgniter4 Cross-Site Request Forgery (CSRF) protection mechanism. Users should upgrade to version 4.1.9. There are workarounds for this vulnerability, but users will still need to code as these after upgrading to v4.1.9. Otherwise, the CSRF protection may be bypassed. If auto-routing is enabled, check the request method in the controller method before processing. If auto-routing is disabled, either avoid using `$routes->add()` and instead use HTTP verbs in routes; or check the request method in the controller method before processing.", "cvss3": {"exploitabilityScore": 2.8, "cvssV3": {"baseSeverity": "HIGH", "confidentialityImpact": "HIGH", "attackComplexity": "LOW", "scope": "UNCHANGED", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "baseScore": 8.8, "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "version": "3.1", "userInteraction": "REQUIRED"}, "impactScore": 5.9}, "published": "2022-02-28T16:15:00", "type": "cve", "title": "CVE-2022-24712", "cwe": ["CWE-352"], "bulletinFamily": "NVD", "cvss2": {"severity": "MEDIUM", "exploitabilityScore": 8.6, "obtainAllPrivilege": false, "userInteractionRequired": true, "obtainOtherPrivilege": false, "cvssV2": {"accessComplexity": "MEDIUM", "confidentialityImpact": "PARTIAL", "availabilityImpact": "PARTIAL", "integrityImpact": "PARTIAL", "baseScore": 6.8, "vectorString": "AV:N/AC:M/Au:N/C:P/I:P/A:P", "version": "2.0", "accessVector": "NETWORK", "authentication": "NONE"}, "impactScore": 6.4, "acInsufInfo": false, "obtainUserPrivilege": false}, "cvelist": ["CVE-2022-24712"], "modified": "2022-03-08T18:08:00", "cpe": [], "id": "CVE-2022-24712", "href": "https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2022-24712", "cvss": {"score": 6.8, "vector": "AV:N/AC:M/Au:N/C:P/I:P/A:P"}, "cpe23": []}]}