Fiber has Insecure CORS Configuration, Allowing Wildcard Origin with Credentials
Published 22 Feb 2024 · Updated 10 Sept 2026
Is your project on an affected github.com/gofiber/fiber/v2?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <2.52.1
- Fixed in
- 2.52.1
go get github.com/gofiber/fiber/v2@v2.52.1Details
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:
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
Is GHSA-fmg4-x8pw-hjhg in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/gofiber/fiber/v2, and gives you the command that fixes it.
More advisories for github.com/gofiber/fiber/v2
- LowCVE-2026-119285Fiber: CORS wildcard origins matched without a dot boundary, allowing credentialed cross-origin reads in github.com/gofiber/fiber · 5 Nov 2026
- MediumCVE-2026-119285Fiber: CORS wildcard origins matched without a dot boundary, allowing credentialed cross-origin reads · 30 Oct 2026
- LowCVE-2026-42554Fiber vulnerable to XSS in AutoFormat Content Negotiation in github.com/gofiber/fiber · 24 Jul 2026
- MediumCVE-2026-45045GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward · 2 Jul 2026
- MediumCVE-2026-42554Fiber vulnerable to XSS in AutoFormat Content Negotiation · 5 May 2026
- LowCVE-2026-25882Fiber has a Denial of Service Vulnerability via Route Parameter Overflow in github.com/gofiber/fiber · 26 Feb 2026
References
- Linkgithub.com/gofiber/fiber/security/advisories/GHSA-fmg4-x8pw-hjhg
- Advisorynvd.nist.gov/vuln/detail/CVE-2024-25124
- Linkgithub.com/gofiber/fiber/commit/f0cd3b44b086544a37886232d0530601f2406c23
- Linkcodeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials
- Linkdeveloper.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials
- Linkfetch.spec.whatwg.org/#cors-protocol-and-credentials
- Packagegithub.com/gofiber/fiber
- Linkgithub.com/gofiber/fiber/releases/tag/v2.52.1
- Linksaturncloud.io/blog/cors-cannot-use-wildcard-in-accesscontrolalloworigin-when-credentials-flag-is-true
- Linkblog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.