GHSA-fmg4-x8pw-hjhg
Fiber has Insecure CORS Configuration, Allowing Wildcard Origin with Credentials
En bref
- Publiée
- Mise à jour
- CVE
- CVE-2024-25124
- Alias
- GO-2024-2574
- CVSS_V3
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L
Description
The CORS middleware allows for insecure configurations that could potentially expose the application to multiple CORS-related vulnerabilities. Specifically, it allows setting the Access-Control-Allow-Origin header to a wildcard ("*") while also having the Access-Control-Allow-Credentials set to true, which goes against recommended security best practices. ## Impact The impact of this misconfiguration is high as it can lead to unauthorized access to sensitive user data and expose the system to various types of attacks listed in the PortSwigger article linked in the references. ## Proof of Concept The code in cors.go allows setting a wildcard in the AllowOrigins while having AllowCredentials set to true, which could lead to various vulnerabilities. ## Potential Solution Here is a potential solution to ensure the CORS configuration is secure: ```go func New(config ...Config) fiber.Handler { if cfg.AllowCredentials && cfg.AllowOrigins == "*" { panic("[CORS] Insecure setup, 'AllowCredentials' is set to true, and 'AllowOrigins' is set to a wildcard.") } // Return new handler goes below } The middleware will not allow insecure configurations when using `AllowCredentials` and `AllowOrigins`. ``` ## Workarounds For the meantime, users are advised to manually validate the CORS configurations in their implementation to ensure that they do not allow a wildcard origin when credentials are enabled. The browser fetch api, browsers and utilities that enforce CORS policies are not affected by this. ## References [MDN Web Docs on CORS Errors](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials) [CodeQL on CORS Misconfiguration](https://codeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials/) [PortSwigger on Exploiting CORS Misconfigurations](http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html) [WhatWG CORS protocol and credentials ](https://fetch.spec.whatwg.org/#cors-protocol-and-credentials)
Paquets affectés
| Paquet | Versions |
|---|---|
| Go · github.com/gofiber/fiber/v2 | introduced 0, fixed 2.52.1 |
Références
- https://github.com/gofiber/fiber/security/advisories/GHSA-fmg4-x8pw-hjhg WEB
- https://nvd.nist.gov/vuln/detail/CVE-2024-25124 ADVISORY
- https://github.com/gofiber/fiber/commit/f0cd3b44b086544a37886232d0530601f2406c23 WEB
- https://codeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials WEB
- https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials WEB
- https://fetch.spec.whatwg.org/#cors-protocol-and-credentials WEB
- https://github.com/gofiber/fiber PACKAGE
- https://github.com/gofiber/fiber/releases/tag/v2.52.1 WEB
- https://saturncloud.io/blog/cors-cannot-use-wildcard-in-accesscontrolalloworigin-when-credentials-flag-is-true WEB
- http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html WEB
Sources
| Source | Licence |
|---|---|
| OSV.dev | CC-BY 4.0 — GitHub Advisory Database |