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


0.0
medium

Snyk CVSS

    Attack Complexity High

    Threat Intelligence

    EPSS 0.05% (21st percentile)
Expand this section
NVD
7.3 high

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()
}