Loading...
Skip to main content

CVE-2026-72817 — Vulnerability in github.com/go-chi/chi/middleware...

HIGH

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

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

Summary

### Summary The vulnerability allows the `Request.RemoteAddr` to be spoofed when determining the request source IP via the `X-Forwarded-For` header. This could result in misidentification of the request source and potentially compromise access control and logging integrity. ### Details Currently, the `RealIP()` implementation splits the `X-Forwarded-For` header by `,` and uses the first IP. https://github.com/go-chi/chi/blob/v5.1.0/middleware/realip.go#L50-L54 However, relying on the first IP in the `X-Forwarded-For` header is insecure because it can be manipulated by attackers to falsify the source IP. Malicious Case: 1. A malicious client sends a request with a forged IP in the X-Forwarded-For header: `X-Forwarded-For: <forged-ip>` 2. The proxy appends the actual client’s IP and forwards the request: `X-Forwarded-For: <forged-ip>,<client-ip>` 3. If the server always uses the first IP, it becomes vulnerable to IP spoofing. Ideally, the implementation should verify IPs starting from the end of the `X-Forwarded-For` header value, skipping trusted IPs within the system, and using the first untrusted IP as the actual client IP. For example, the `labstack/echo` web framework processes the `X-Forwarded-For` header by checking IPs from the end, skipping trusted IPs, and using the first untrusted IP as the client's ip. https://github.com/labstack/echo/blob/v4.13.2/ip.go#L261-L273 ### PoC #### 1. Run the Go application with the following code: ```go package main import ( "fmt" "log" "net/http" "github.com/go-chi/chi/v5/middleware" ) func main() { // Set handler to print the remote address handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln( w, fmt.Sprintf("remote addr: %s (want 192.0.2.1)", r.RemoteAddr), ) }) // Use RealIP middleware log.Fatal(http.ListenAndServe(":8080", middleware.RealIP(handler))) } ``` #### 2. Send a request to the server using curl with a manipulated X-Forwarded-For header: ``` $ curl localhost:8080 -H 'X-Forwarded-For: 192.0.2.2, 192.0.2.1' remote addr: 192.0.2.2 (want 192.0.2.1) ``` ### Impact This vulnerability can lead to a request source IP spoofing issue, which may allow attackers to bypass access controls or falsify request logs. It primarily affects systems that rely on X-Forwarded-For to determine the actual client IP, particularly in scenarios where intermediary proxies or load balancers are involved.

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/middleware
go
All versionsRange-based data available
github.com/go-chi/chi/v4/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.

  • CWE-346
    Origin Validation ErrorMITRE

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-72817?
chi Middleware Vulnerable to Potential IP Spoofing via `X-Forwarded-For` Header in `Request.RemoteAddr` Resolution 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-72817?
CVE-2026-72817 affects github.com/go-chi/chi/middleware, github.com/go-chi/chi/v4/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-72817 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-9g5q-2w5x-hmxf
GO-2026-5775

Related CVEs

  • CVE-2026-107809
    HIGH

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

  • 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

  • CVE-2026-72816
    HIGH

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

Check if you're affected

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

Scan Your Dependencies