Go Trust Proxy On

Description

This detector identifies insecure proxy configuration in Gin web framework applications where SetTrustedProxies is called with wildcard values (like "*" or "0.0.0.0/0"). This misconfiguration allows any proxy to be trusted, potentially enabling IP spoofing attacks where malicious actors can manipulate client IP addresses and bypass security controls.

Weakness:

157 - Unrestricted access between network segments

Category: Access Subversion

Detection Strategy

    Code must import the Gin web framework library (github.com/gin-gonic/gin)

    File being analyzed must not be a test file

    Code contains a method call ending with 'SetTrustedProxies'

    The first argument to SetTrustedProxies contains wildcard proxy definitions that would trust all proxies indiscriminately

Vulnerable code example

package main

import (
	"net/http"
	"github.com/gin-gonic/gin"
)

func VulnerableProxy() *gin.Engine {...

✅ Secure code example

package main

import (
	"net/http"
	"github.com/gin-gonic/gin"
)

func VulnerableProxy() *gin.Engine {...