CVE-2024-25124: Github.com/gofiber/fiber/v2 Fiber Has Insecure CORS Configuration, Vulnerability
CRITICALCVE-2024-25124 is a CRITICAL (CVSS 9.4) fiber has insecure cors configuration, vulnerability (CWE-346: Origin Validation Error) affecting Github.com/gofiber/fiber/v2 libraries in the Go ecosystem. The issue involves fiber has insecure cors configuration, allowing wildcard origin with credentials. Remediation is available by upgrading affected packages to version 2.52.1.
CVE-2024-25124 at a Glance
Security Impact
CVSS: 9.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L).
How to Fix CVE-2024-25124
To remediate this vulnerability, upgrade all affected Github.com/gofiber/fiber/v2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/gofiber/fiber/v2 to 2.52.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/gofiber/fiber/v2
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-25124, inspect your project dependencies for Github.com/gofiber/fiber/v2:
inspect dependencies for github.com/gofiber/fiber/v2
Analyze the terminal output to locate any version of Github.com/gofiber/fiber/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.52.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-346: Origin Validation Error, where the product does not properly verify that the source of data or communication is valid. In Github.com/gofiber/fiber/v2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-25124 Affected Github.com/gofiber/fiber/v2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/gofiber/fiber/v2
|
Go |
< 2.52.1
|
2.52.1
|
References
Frequently Asked Questions
What is CVE-2024-25124?
Which Github.com/gofiber/fiber/v2 versions are affected?
What version fixes CVE-2024-25124?
Is github.com/gofiber/fiber/v2 affected?
What is the CVSS score of CVE-2024-25124?
What CWE is associated with CVE-2024-25124?
How can I check Go dependencies for CVE-2024-25124?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fmg4-x8pw-hjhg",
"modified" : "2024-02-26T15:48:31Z",
"published" : "2024-02-22T18:25:18Z",
"aliases" : [ "CVE-2024-25124" ],
"summary" : "Fiber has Insecure CORS Configuration, Allowing Wildcard Origin with Credentials",
"details" : "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.\n\n## Impact\nThe 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.\n\n## Proof of Concept\nThe code in cors.go allows setting a wildcard in the AllowOrigins while having AllowCredentials set to true, which could lead to various vulnerabilities.\n\n## Potential Solution\nHere is a potential solution to ensure the CORS configuration is secure:\n\n```go\nfunc New(config ...Config) fiber.Handler {\n if cfg.AllowCredentials && cfg.AllowOrigins == \"*\" {\n panic(\"[CORS] Insecure setup, 'AllowCredentials' is set to true, and 'AllowOrigins' is set to a wildcard.\")\n }\n // Return new handler goes below\n}\n\nThe middleware will not allow insecure configurations when using `AllowCredentials` and `AllowOrigins`.\n```\n\n## Workarounds\nFor 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.\n\n## References\n[MDN Web Docs on CORS Errors](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials)\n[CodeQL on CORS Misconfiguration](https://codeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials/)\n[PortSwigger on Exploiting CORS Misconfigurations](http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html)\n[WhatWG CORS protocol and credentials ](https://fetch.spec.whatwg.org/#cors-protocol-and-credentials)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/gofiber/fiber/v2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.52.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/gofiber/fiber/security/advisories/GHSA-fmg4-x8pw-hjhg"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-25124"
}, {
"type" : "WEB",
"url" : "https://github.com/gofiber/fiber/commit/f0cd3b44b086544a37886232d0530601f2406c23"
}, {
"type" : "WEB",
"url" : "https://codeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials"
}, {
"type" : "WEB",
"url" : "https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSNotSupportingCredentials"
}, {
"type" : "WEB",
"url" : "https://fetch.spec.whatwg.org/#cors-protocol-and-credentials"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/gofiber/fiber"
}, {
"type" : "WEB",
"url" : "https://github.com/gofiber/fiber/releases/tag/v2.52.1"
}, {
"type" : "WEB",
"url" : "https://saturncloud.io/blog/cors-cannot-use-wildcard-in-accesscontrolalloworigin-when-credentials-flag-is-true"
}, {
"type" : "WEB",
"url" : "http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-346" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-02-22T18:25:18Z",
"nvd_published_at" : "2024-02-21T21:15:09Z"
}
}