CVE-2023-45128: Github.com/gofiber/fiber/v2 CSRF Token Reuse Vulnerability Vulnerability

CRITICAL
Advisory Identifier: GHSA-94w9-97p3-p368
CVSS 9.6
CWE-20
Published
Advisory Summary

CVE-2023-45128 is a CRITICAL (CVSS 9.6) csrf token reuse vulnerability vulnerability (CWE-20: Improper Input Validation) affecting Github.com/gofiber/fiber/v2 libraries in the Go ecosystem. The issue involves csrf token reuse vulnerability. Remediation is available by upgrading affected packages to version 2.50.0.

CVE-2023-45128 at a Glance

CVE Identifier CVE-2023-45128
GHSA Identifier GHSA-94w9-97p3-p368
Severity CRITICAL
CVSS v3.1 Base Score 9.6
CWE Classification CWE-20: Improper Input Validation
Affected Product Github.com/gofiber/fiber/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.6

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:R/S:C/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2023-45128

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.50.0
Upgrade github.com/gofiber/fiber/v2 to 2.50.0
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-2023-45128, 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.50.0), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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

A Cross-Site Request Forgery (CSRF) vulnerability has been identified in the application, which allows an attacker to inject arbitrary values and forge malicious requests on behalf of a user. This vulnerability can allow an attacker to inject arbitrary values without any authentication, or perform various malicious actions on behalf of an authenticated user, potentially compromising the security and integrity of the application. ## Vulnerability Details The vulnerability is caused by improper validation and enforcement of CSRF tokens within the application. The following issues were identified: 1. **Token Injection**: For 'safe' methods, the token was extracted from the cookie and saved to storage without further validation or sanitization. 2. **Lack of Token Association**: The CSRF token was validated against tokens in storage but not associated with a session, nor by using a Double Submit Cookie Method, allowing for token reuse. ### Specific Go Packages Affected github.com/gofiber/fiber/v2/middleware/csrf ## Remediation To remediate this vulnerability, it is recommended to take the following actions: 1. **Update the Application**: Upgrade the application to a fixed version with a patch for the vulnerability. 2. **Implement Proper CSRF Protection**: Review the updated documentation and ensure your application's CSRF protection mechanisms follow best practices. 4. **Choose CSRF Protection Method**: Select the appropriate CSRF protection method based on your application's requirements, either the Double Submit Cookie method or the Synchronizer Token Pattern using sessions. 5. **Security Testing**: Conduct a thorough security assessment, including penetration testing, to identify and address any other security vulnerabilities. ## Defence-in-depth Users should take additional security measures like captchas or Two-Factor Authentication (2FA) and set Session cookies with SameSite=Lax or SameSite=Secure, and the Secure and HttpOnly attributes.

CVE-2023-45128 Affected Github.com/gofiber/fiber/v2 Versions

1 component(s)
Fixed Versions:
2.50.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/gofiber/fiber/v2
Go
< 2.50.0
2.50.0

References

Frequently Asked Questions

What is CVE-2023-45128?
CVE-2023-45128 is a security vulnerability in Github.com/gofiber/fiber/v2 involving CSRF Token Reuse Vulnerability under CWE-20: Improper Input Validation.
Which Github.com/gofiber/fiber/v2 versions are affected?
Affected versions include releases prior to 2.50.0 across affected packages: github.com/gofiber/fiber/v2.
What version fixes CVE-2023-45128?
Upgrading to 2.50.0 (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.50.0. Upgrade your dependency to 2.50.0 or later.
What is the CVSS score of CVE-2023-45128?
CVE-2023-45128 has a CVSS v3.1 base score of 9.6 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2023-45128?
CVE-2023-45128 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check Go dependencies for CVE-2023-45128?
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-94w9-97p3-p368",
  "modified" : "2023-10-23T21:09:50Z",
  "published" : "2023-10-17T12:40:37Z",
  "aliases" : [ "CVE-2023-45128" ],
  "summary" : "CSRF Token Reuse Vulnerability",
  "details" : "A Cross-Site Request Forgery (CSRF) vulnerability has been identified in the application, which allows an attacker to inject arbitrary values and forge malicious requests on behalf of a user. This vulnerability can allow an attacker to inject arbitrary values without any authentication, or perform various malicious actions on behalf of an authenticated user, potentially compromising the security and integrity of the application.\n\n## Vulnerability Details\n\nThe vulnerability is caused by improper validation and enforcement of CSRF tokens within the application. The following issues were identified:\n\n1. **Token Injection**: For 'safe' methods, the token was extracted from the cookie and saved to storage without further validation or sanitization.\n\n2. **Lack of Token Association**: The CSRF token was validated against tokens in storage but not associated with a session, nor by using a Double Submit Cookie Method, allowing for token reuse.\n\n### Specific Go Packages Affected\ngithub.com/gofiber/fiber/v2/middleware/csrf\n\n## Remediation\n\nTo remediate this vulnerability, it is recommended to take the following actions:\n\n1. **Update the Application**: Upgrade the application to a fixed version with a patch for the vulnerability.\n\n2. **Implement Proper CSRF Protection**: Review the updated documentation and ensure your application's CSRF protection mechanisms follow best practices.\n\n4. **Choose CSRF Protection Method**: Select the appropriate CSRF protection method based on your application's requirements, either the Double Submit Cookie method or the Synchronizer Token Pattern using sessions.\n\n5. **Security Testing**: Conduct a thorough security assessment, including penetration testing, to identify and address any other security vulnerabilities.\n\n## Defence-in-depth\n\nUsers should take additional security measures like captchas or Two-Factor Authentication (2FA) and set Session cookies with SameSite=Lax or SameSite=Secure, and the Secure and HttpOnly attributes.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/gofiber/fiber/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.50.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gofiber/fiber/security/advisories/GHSA-94w9-97p3-p368"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-45128"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gofiber/fiber/commit/8c3916dbf4ad2ed427d02c6eb63ae8b2fa8f019a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gofiber/fiber/commit/b50d91d58ecdff2a330bf07950244b6c4caf65b1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gofiber/fiber"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-10-17T12:40:37Z",
    "nvd_published_at" : "2023-10-16T21:15:11Z"
  }
}