{"id":"GHSA-745p-r637-7vvp","aliases":["BIT-codeigniter-2022-39284","CVE-2022-39284"],"title":"Codeigniter4's Secure or HttpOnly flag set in Config\\Cookie is not reflected in Cookies issued","titleSource":"OSV","descriptionSource":"OSV","declaredSeverity":"LOW","description":"### Impact\nSetting `$secure` or `$httponly` value to `true` in `Config\\Cookie` is not reflected in `set_cookie()` or `Response::setCookie()`.\n\n> **Note**\n> This vulnerability does not affect session cookies.\n\nThe following code does not issue a cookie with the secure flag even if you set `$secure = true` in `Config\\Cookie`.\n\n```php\nhelper('cookie');\n\n$cookie = [\n    'name'  => $name,\n    'value' => $value,\n];\nset_cookie($cookie);\n// or\n$this->response->setCookie($cookie);\n```\n\n### Patches\nUpgrade to v4.2.7 or later.\n\n### Workarounds\n1. Specify the options explicitly.\n   ```php\n   helper('cookie');\n\n   $cookie = [\n       'name'     => $name,\n       'value'    => $value,\n       'secure'   => true,\n       'httponly' => true,\n   ];\n   set_cookie($cookie);\n   // or\n   $this->response->setCookie($cookie);\n   ```\n2. Use Cookie object.\n   ```php\n   use CodeIgniter\\Cookie\\Cookie;\n\n   helper('cookie');\n\n   $cookie = new Cookie($name, $value);\n   set_cookie($cookie);\n   // or\n   $this->response->setCookie($cookie);\n   ```\n\n### References\n- https://codeigniter4.github.io/userguide/helpers/cookie_helper.html#set_cookie\n- https://codeigniter4.github.io/userguide/outgoing/response.html#CodeIgniter\\HTTP\\Response::setCookie\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","severity":"low","score":2.6,"published":"2022-10-06T20:01:41.000Z","modified":"2024-02-16T08:04:07.612Z","withdrawn":false,"knownExploited":false,"affected":[{"ecosystem":"Packagist","name":"codeigniter4/framework","sources":[{"name":"OSV · GHSA-745p-r637-7vvp","url":"https://osv.dev/vulnerability/GHSA-745p-r637-7vvp"}],"ranges":[{"events":[{"introduced":"0"},{"fixed":"4.2.7"}],"type":"ECOSYSTEM"}],"versions":["4.0.0","4.0.0-rc.4","v4.0.0-alpha.3","v4.0.0-alpha.4","v4.0.0-alpha.5","v4.0.0-beta.1","v4.0.0-beta.2","v4.0.0-beta.3","v4.0.0-beta.4","v4.0.0-rc.1","v4.0.0-rc.2","v4.0.0-rc.2.1","v4.0.0-rc.3","v4.0.1","v4.0.2","v4.0.3","v4.0.4","v4.0.5","v4.1.0","v4.1.1","v4.1.2","v4.1.3","v4.1.4","v4.1.5","v4.1.6","v4.1.7","v4.1.8","v4.1.9","v4.2.0","v4.2.1","v4.2.2","v4.2.3","v4.2.4","v4.2.5","v4.2.6"],"fixed":["4.2.7"]}],"sourceAffected":[],"references":["https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-745p-r637-7vvp","https://nvd.nist.gov/vuln/detail/CVE-2022-39284","https://github.com/codeigniter4/CodeIgniter4/issues/6540","https://github.com/codeigniter4/CodeIgniter4/pull/6544","https://codeigniter4.github.io/userguide/helpers/cookie_helper.html#set_cookie","https://codeigniter4.github.io/userguide/outgoing/response.html#CodeIgniter%5CHTTP%5CResponse::setCookie","https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies","https://github.com/FriendsOfPHP/security-advisories/blob/master/codeigniter4/framework/CVE-2022-39284.yaml","https://github.com/codeigniter4/CodeIgniter4"],"sources":[{"name":"OSV","id":"GHSA-745p-r637-7vvp","modified":"2024-02-16T08:04:07.612498Z","url":"https://osv.dev/vulnerability/GHSA-745p-r637-7vvp"}],"assessments":[{"source":"OSV","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:L/I:N/A:N","score":2.6}],"products":[],"remediation":[],"kev":{"status":"not-listed","checkedAt":"2026-10-28T23:25:34.350Z"},"coverage":[{"source":"NVD","status":"not-checked"},{"source":"GHSA","status":"not-checked"},{"source":"EUVD","status":"not-checked"},{"source":"EPSS","status":"not-checked"}],"evidence":[]}