CVE-2024-25124: Fiber has Insecure CORS Configuration, Allowing Wildcard Origin with Credentials
Fiber is a web framework written in go. Prior to version 2.52.1, 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. 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. Version 2.52.1 contains a patch for this issue. As a workaround, users may 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, as well as browsers and utilities that enforce CORS policies, are not affected by this.
Other sources
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 CodeQL on CORS Misconfiguration PortSwigger on Exploiting CORS Misconfigurations WhatWG CORS protocol and credentials
— GitHub
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/gofiber/fiber/v2to a version that resolves this vulnerability.Fixed in 2.52.1 - Upgrade
Upgrade
Fiber CORS middlewareto a version that resolves this vulnerability.Fixed in 2.52.1 - Configuration
If using Fiber’s CORS middleware, manually validate/change your CORS configuration so that when `AllowCredentials` is enabled, `AllowOrigins` is not set to the wildcard `"*"` (since wildcard origin with credentials is insecure).
Fiber (CORS middleware) AllowOrigins = not "*" when AllowCredentials is true
Event History
Frequently Asked Questions
What is the severity of CVE-2024-25124?
CVE-2024-25124 has a moderate severity level due to its potential to enable multiple CORS-related vulnerabilities.
How do I fix CVE-2024-25124?
To fix CVE-2024-25124, upgrade to Fiber version 2.52.1 or later.
What are the potential risks of CVE-2024-25124?
The risks include exposure to cross-origin resource sharing vulnerabilities, which can lead to unauthorized access to sensitive data.
Which versions of Fiber are affected by CVE-2024-25124?
CVE-2024-25124 affects Fiber versions prior to 2.52.1.
What is the recommended action for users of Fiber regarding CVE-2024-25124?
Users of Fiber are recommended to immediately update to version 2.52.1 or later to mitigate the vulnerability.