Loading...
Skip to main content

CVE-2026-72816 — Vulnerability in...

HIGH

chi's RealIP Middleware allows IP spoofing via unvalidated X-Forwarded-For header

Published June 25, 2026Updated September 10, 2026Source: osv

Summary

### Summary realip middleware in go-chi/chi trusts headers like x-forwarded-for without checking them, so attackers can fake their ip and bypass rate limits or access controls ### Details the vuln is in middleware/realip.go , the realIP() function pulls IPs straight from client headers and replaces r.RemoteAddr without checking if the request came from a trusted proxy ```go func realIP(r *http.Request) string { var ip string if tcip := r.Header.Get(trueClientIP); tcip != "" { ip = tcip // controlled by attacker } else if xrip := r.Header.Get(xRealIP); xrip != "" { ip = xrip // controlled by attacker } else if xff := r.Header.Get(xForwardedFor); xff != "" { ip, _, _ = strings.Cut(xff, ",") // controlled by attacker } // ... return ip } ``` no trusted proxy cidr check in place, any client can send these headers ### PoC create a server with chi and use realip middleware ```go package main import ( "fmt" "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func main() { r := chi.NewRouter() r.Use(middleware.RealIP) r.Get("/admin", func(w http.ResponseWriter, r *http.Request) { // ip-based access control got bypassed if r.RemoteAddr == "127.0.0.1" { w.Write([]byte("SECRET ADMIN DATA")) return } http.Error(w, "Forbidden", 403) }) http.ListenAndServe(":8080", r) } ``` spoofed the ip to bypass access control ```bash curl -H "X-Forwarded-For: 127.0.0.1" http://localhost:8080/admin ``` ### Impact - ip-based access control bypass lets attackers reach restricted endpoints - rate limiting bypass lets attackers avoid limits by rotating spoofed ips - audit logs show fake ips picked by attacker instead of real ones - attackers can get around geo ip restrictions ## Remediation Recommendation validate proxy cidr first before trusting forwarded ip headers ```go // add your reverse proxy ip addresses here var trustedProxies = []net.IPNet{ {IP: net.ParseIP("10.0.0.0"), Mask: net.CIDRMask(8, 32)}, {IP: net.ParseIP("172.16.0.0"), Mask: net.CIDRMask(12, 32)}, {IP: net.ParseIP("192.168.0.0"), Mask: net.CIDRMask(16, 32)}, } func isTrustedProxy(ip net.IP) bool { for _, cidr := range trustedProxies { if cidr.Contains(ip) { return true } } return false } ```

Advisory Timeline

  • First published June 25, 2026 (109 days ago).
  • Last revised September 10, 2026 — 76 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Go
Update github.com/go-chi/chi/v5/middleware to 5.3.0 or later
go get github.com/go-chi/chi/v5/middleware@v5.3.0

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (5)

Affects 1 ecosystem: go (5).

PackageEcosystemAffectedFixed In
github.com/go-chi/chi/v4/middleware
go
All versionsRange-based data available
github.com/go-chi/chi/middleware
go
All versionsRange-based data available
github.com/go-chi/chi/v5/middleware
go
All versions5.3.0
github.com/go-chi/chi/v3/middleware
go
All versionsRange-based data available
github.com/go-chi/chi/v2/middleware
go
All versionsRange-based data available

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N/E:P

Frequently Asked Questions

What is CVE-2026-72816?
chi's RealIP Middleware allows IP spoofing via unvalidated X-Forwarded-For header This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
How do I check if my project is affected by CVE-2026-72816?
CVE-2026-72816 affects github.com/go-chi/chi/v4/middleware, github.com/go-chi/chi/middleware and github.com/go-chi/chi/v5/middleware (and 2 more). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-72816 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
7.5

High exploitability or significant impact. Prioritize remediation within days.

Also Known As

GHSA-rjr7-jggh-pgcp
GO-2026-5777

Related CVEs

  • CVE-2026-107809
    HIGH

    Nginx-UI AuthRequired token cookie fallback enables CSRF against management APIs

  • CVE-2026-72817
    HIGH

    chi Middleware Vulnerable to Potential IP Spoofing via `X-Forwarded-For` Header in `Request.RemoteAddr` Resolution

  • CVE-2026-107813
    HIGH

    Nginx UI: Incomplete fix of CVE-2026-84315 - the api/cluster router was not - wrapped in RequireSecureSession, so those sensitive mutations run without OTP step-up

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies