CVE-2024-25124: Github.com/gofiber/fiber/v2 Fiber Has Insecure CORS Configuration, Vulnerability

CRITICAL
Advisory Identifier: GHSA-fmg4-x8pw-hjhg
CVSS 9.4
CWE-346
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2024-25124
GHSA Identifier GHSA-fmg4-x8pw-hjhg
Severity CRITICAL
CVSS v3.1 Base Score 9.4
CWE Classification CWE-346: Origin Validation Error
Affected Product Github.com/gofiber/fiber/v2
Package Ecosystem Go
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (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.

github.com/gofiber/fiber/v2 fixed: 2.52.1
Upgrade github.com/gofiber/fiber/v2 to 2.52.1
Verify Direct and Transitive Dependencies

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

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)

CVE-2024-25124 Affected Github.com/gofiber/fiber/v2 Versions

1 component(s)
Fixed Versions:
2.52.1
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?
CVE-2024-25124 is a security vulnerability in Github.com/gofiber/fiber/v2 involving Fiber has Insecure CORS Configuration, Allowing Wildcard Origin with Credentials under CWE-346: Origin Validation Error.
Which Github.com/gofiber/fiber/v2 versions are affected?
Affected versions include releases prior to 2.52.1 across affected packages: github.com/gofiber/fiber/v2.
What version fixes CVE-2024-25124?
Upgrading to 2.52.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/gofiber/fiber/v2 affected?
Yes, github.com/gofiber/fiber/v2 is affected in releases prior to 2.52.1. Upgrade your dependency to 2.52.1 or later.
What is the CVSS score of CVE-2024-25124?
CVE-2024-25124 has a CVSS v3.1 base score of 9.4 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2024-25124?
CVE-2024-25124 is classified under CWE-346: Origin Validation Error (The product does not properly verify that the source of data or communication is valid.).
How can I check Go dependencies for CVE-2024-25124?
Run the dependency tree command: 'inspect dependencies for github.com/gofiber/fiber/v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}