CVE-2023-29401: Github.com/gin gonic/gin Gin Web Framework Does Not Vulnerability

MODERATE
Advisory Identifier: GHSA-2c4m-59x9-fr2g
CVSS 4.3
CWE-494
Published
Advisory Summary

CVE-2023-29401 is a MODERATE (CVSS 4.3) gin web framework does not vulnerability (CWE-494: Download of Code Without Integrity Check) affecting Github.com/gin gonic/gin libraries in the Go ecosystem. The issue involves gin web framework does not properly sanitize filename parameter of context.fileattachment function. Remediation is available by upgrading affected packages to version 1.9.1.

CVE-2023-29401 at a Glance

CVE Identifier CVE-2023-29401
GHSA Identifier GHSA-2c4m-59x9-fr2g
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-494: Download of Code Without Integrity Check
Affected Product Github.com/gin gonic/gin
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.3

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:U/C:N/I:L/A:N).

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

How to Fix CVE-2023-29401

To remediate this vulnerability, upgrade all affected Github.com/gin gonic/gin 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/gin-gonic/gin fixed: 1.9.1
Upgrade github.com/gin-gonic/gin to 1.9.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/gin-gonic/gin

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-29401, inspect your project dependencies for Github.com/gin gonic/gin:

inspect dependencies for github.com/gin-gonic/gin

Analyze the terminal output to locate any version of Github.com/gin gonic/gin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.9.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-494: Download of Code Without Integrity Check, where the product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. In Github.com/gin gonic/gin, 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 filename parameter of the Context.FileAttachment function is not properly sanitized. A maliciously crafted filename can cause the Content-Disposition header to be sent with an unexpected filename value or otherwise modify the Content-Disposition header. For example, a filename of "setup.bat";x=.txt" will be sent as a file named "setup.bat". If the FileAttachment function is called with names provided by an untrusted source, this may permit an attacker to cause a file to be served with a name different than provided. Maliciously crafted attachment file name can modify the Content-Disposition header.

CVE-2023-29401 Affected Github.com/gin gonic/gin Versions

1 component(s)
Fixed Versions:
1.9.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/gin-gonic/gin
Go
≥ 1.3.1-0.20190301021747-ccb9e902956d
< 1.9.1
1.9.1

References

Frequently Asked Questions

What is CVE-2023-29401?
CVE-2023-29401 is a security vulnerability in Github.com/gin gonic/gin involving Gin Web Framework does not properly sanitize filename parameter of Context.FileAttachment function under CWE-494: Download of Code Without Integrity Check.
Which Github.com/gin gonic/gin versions are affected?
Affected versions include releases prior to 1.9.1 across affected packages: github.com/gin-gonic/gin.
What version fixes CVE-2023-29401?
Upgrading to 1.9.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/gin-gonic/gin affected?
Yes, github.com/gin-gonic/gin is affected in releases prior to 1.9.1. Upgrade your dependency to 1.9.1 or later.
What is the CVSS score of CVE-2023-29401?
CVE-2023-29401 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2023-29401?
CVE-2023-29401 is classified under CWE-494: Download of Code Without Integrity Check (The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code.).
How can I check Go dependencies for CVE-2023-29401?
Run the dependency tree command: 'inspect dependencies for github.com/gin-gonic/gin'. 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-2c4m-59x9-fr2g",
  "modified" : "2023-06-16T17:57:38Z",
  "published" : "2023-05-12T20:19:25Z",
  "aliases" : [ "CVE-2023-29401" ],
  "summary" : "Gin Web Framework does not properly sanitize filename parameter of Context.FileAttachment function",
  "details" : "The filename parameter of the Context.FileAttachment function is not properly sanitized. A maliciously crafted filename can cause the Content-Disposition header to be sent with an unexpected filename value or otherwise modify the Content-Disposition header. For example, a filename of \"setup.bat&quot;;x=.txt\" will be sent as a file named \"setup.bat\".\n\nIf the FileAttachment function is called with names provided by an untrusted source, this may permit an attacker to cause a file to be served with a name different than provided. Maliciously crafted attachment file name can modify the Content-Disposition header.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/gin-gonic/gin"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.3.1-0.20190301021747-ccb9e902956d"
      }, {
        "fixed" : "1.9.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-29401"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gin-gonic/gin/issues/3555"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gin-gonic/gin/pull/3556"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gin-gonic/gin"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gin-gonic/gin/releases/tag/v1.9.1"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2023-1737"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-494" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-12T20:19:25Z",
    "nvd_published_at" : "2023-06-08T21:15:16Z"
  }
}