{"id":"CVE-2026-72817","aliases":["CVE-2026-72817","GHSA-9g5q-2w5x-hmxf","GO-2026-5775"],"related":["CGA-vphg-6r8r-9x6m"],"kind":"vulnerability","state":"published","title":"go-chi chi 0.9.0 before 5.3.0 IP Spoofing via X-Forwarded-For","summary":"go-chi/chi versions 0.9.0 before 5.3.0 contains an IP spoofing vulnerability in the RealIP middleware, which resolves the request source IP (Request.RemoteAddr) using the first IP in the X-Forwarded-For header without validating trusted proxies. A malicious client can prepend a forged IP as the first value of the X-Forwarded-For header to spoof the request source IP, potentially bypassing access controls or falsifying request logs.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"go-chi/chi versions 0.9.0 before 5.3.0 contains an IP spoofing vulnerability in the RealIP middleware, which resolves the request source IP (Request.RemoteAddr) using the first IP in the X-Forwarded-For header without validating trusted proxies. A malicious client can prepend a forged IP as the first value of the X-Forwarded-For header to spoof the request source IP, potentially bypassing access controls or falsifying request logs.","source":"cvelist"},{"lang":"en","text":"### Summary\nThe 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.\n\n### Details\nCurrently, the `RealIP()` implementation splits the `X-Forwarded-For` header by `,` and uses the first IP.\nhttps://github.com/go-chi/chi/blob/v5.1.0/middleware/realip.go#L50-L54\n\nHowever, 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.\n\nMalicious Case:\n1. A malicious client sends a request with a forged IP in the X-Forwarded-For header: `X-Forwarded-For: <forged-ip>`\n2. The proxy appends the actual client’s IP and forwards the request: `X-Forwarded-For: <forged-ip>,<client-ip>`\n3. If the server always uses the first IP, it becomes vulnerable to IP spoofing.\n\nIdeally, 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.\n\nFor 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.\nhttps://github.com/labstack/echo/blob/v4.13.2/ip.go#L261-L273\n\n### PoC\n#### 1. Run the Go application with the following code:\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n\n    \"github.com/go-chi/chi/v5/middleware\"\n)\n\nfunc main() {\n    // Set handler to print the remote address\n    handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        fmt.Fprintln(\n            w,\n            fmt.Sprintf(\"remote addr: %s (want 192.0.2.1)\", r.RemoteAddr),\n        )\n    })\n    // Use RealIP middleware\n    log.Fatal(http.ListenAndServe(\":8080\", middleware.RealIP(handler)))\n}\n```\n#### 2. Send a request to the server using curl with a manipulated X-Forwarded-For header:\n```\n$ curl localhost:8080 -H 'X-Forwarded-For: 192.0.2.2, 192.0.2.1'\nremote addr: 192.0.2.2 (want 192.0.2.1)\n```\n\n### Impact\nThis 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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Chi Middleware vulnerable to IP spoofing via X-Forwarded-For header in github.com/go-chi/chi","format":"markdown","source":"go"}],"published":"2026-06-25T18:18:56.000Z","modified":"2026-10-08T16:17:35.923Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"}],"cwes":["CWE-345","CWE-346"],"affected":[{"ranges":[{"type":"semver","introduced":"0.9.0","fixed":"5.3.0","status":"affected"},{"type":"semver","version":"5.3.0","status":"unaffected"}],"vendor":"go-chi","product":"chi","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.9.0","status":"affected","lastAffected":"1.5.5"}],"ecosystem":"Go","package":"github.com/go-chi/chi/middleware","purl":"pkg:golang/github.com/go-chi/chi/middleware","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"2.1.1"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v2/middleware","purl":"pkg:golang/github.com/go-chi/chi/v2/middleware","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"3.3.5"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v3/middleware","purl":"pkg:golang/github.com/go-chi/chi/v3/middleware","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"4.1.3"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v4/middleware","purl":"pkg:golang/github.com/go-chi/chi/v4/middleware","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.3.0"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v5/middleware","purl":"pkg:golang/github.com/go-chi/chi/v5/middleware","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.3.0"}],"ecosystem":"Go","package":"github.com/go-chi/chi/v5","purl":"pkg:golang/github.com/go-chi/chi/v5","source":"go"}],"references":[{"url":"https://github.com/go-chi/chi/security/advisories/GHSA-9g5q-2w5x-hmxf","tags":["advisory","vendor-advisory","web"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://www.vulncheck.com/advisories/go-chi-chi-before-ip-spoofing-via-x-forwarded-for","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/go-chi/chi","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/go-chi/chi/releases/tag/v5.3.0","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/go-chi/chi/pull/967","tags":["fix"],"sources":["go"]}],"credits":["convto"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-08-17T15:44:55.846Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-72817","url":"https://www.cve.org/CVERecord?id=CVE-2026-72817","licence":"CVE Terms of Use","modified":"2026-10-08T15:24:32.174Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9g5q-2w5x-hmxf","url":"https://github.com/advisories/GHSA-9g5q-2w5x-hmxf","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:49.185Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5775","url":"https://pkg.go.dev/vuln/GO-2026-5775","licence":"CC-BY-4.0","modified":"2026-08-15T05:19:13.029Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-72817","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-72817","licence":"Public domain","modified":"2026-10-08T16:17:35.923Z"}],"updatedAt":"2026-11-25T22:59:32.903Z","epss":{"score":0.0015,"percentile":0.04419,"date":"2026-12-01T12:00:22.000Z"}}