Improper Input Validation Affecting github.com/gin-gonic/gin package, versions <1.9.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    EPSS
    0.13% (49th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-GOLANG-GITHUBCOMGINGONICGIN-3324285
  • published 3 May 2023
  • disclosed 17 Feb 2023
  • credit t0rchwo0d

How to fix?

Upgrade github.com/gin-gonic/gin to version 1.9.0 or higher.

Overview

github.com/gin-gonic/gin is a package that implements a HTTP web framework called gin.

Affected versions of this package are vulnerable to Improper Input Validation by allowing an attacker to use a specially crafted request via the X-Forwarded-Prefix header, potentially leading to cache poisoning.

Note: Although this issue does not pose a significant threat on its own it can serve as an input vector for other more impactful vulnerabilities. However, successful exploitation may depend on the server configuration and whether the header is used in the application logic.

PoC

package main

import (
    "net/http"

    "github.com/gin-gonic/gin"
)

func main() {

    r := gin.Default()

    r.GET("/bug", func(c *gin.Context) {
        c.JSON(http.StatusBadRequest, gin.H{"msg": "bug"})
    })

    r.Run()
}

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
5.6 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    High
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    Low
  • Integrity (I)
    Low
  • Availability (A)
    Low
Expand this section

NVD

7.3 high