{"id":"CVE-2026-45045","aliases":["CVE-2026-45045","GHSA-gcfq-8gqf-4876","GO-2026-5887"],"related":[],"kind":"vulnerability","state":"published","title":"Fiber: X-Real-IP Spoofing via Header.Add() in BalancerForward","summary":"Fiber is an Express inspired web framework written in Go. Prior to 3.3.0 and 2.52.14, the BalancerForward proxy helper in middleware/proxy/proxy.go uses Header.Add() instead of Header.Set() when injecting X-Real-IP, allowing an attacker-supplied first X-Real-IP value to be forwarded to upstream servers for logging, rate limiting, and access control. This issue is fixed in version 3.3.0 and 2.52.14.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Fiber is an Express inspired web framework written in Go. Prior to 3.3.0 and 2.52.14, the BalancerForward proxy helper in middleware/proxy/proxy.go uses Header.Add() instead of Header.Set() when injecting X-Real-IP, allowing an attacker-supplied first X-Real-IP value to be forwarded to upstream servers for logging, rate limiting, and access control. This issue is fixed in version 3.3.0 and 2.52.14.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe `BalancerForward` proxy helper in GoFiber uses `Header.Add()` instead of `Header.Set()` when injecting the `X-Real-IP` header. This appends the real client IP as a second header value rather than replacing any attacker-supplied value. Upstream servers that read the first `X-Real-IP` header (nginx, Express, most HTTP servers) use the attacker's spoofed IP for logging, rate limiting, and access control.\n\n## Vulnerable Code\n\n**File:** `middleware/proxy/proxy.go`, lines 270-285\n\n```go\nfunc BalancerForward(servers []string, clients ...*fasthttp.Client) fiber.Handler {\n    r := &roundrobin{\n        current: 0,\n        pool:    servers,\n    }\n    return func(c fiber.Ctx) error {\n        server := r.get()\n        if !strings.HasPrefix(server, \"http\") {\n            server = \"http://\" + server\n        }\n        c.Request().Header.Add(\"X-Real-IP\", c.IP())   // line 282: Add, not Set\n        return Do(c, server+c.OriginalURL(), clients...)\n    }\n}\n```\n\n## Data Flow\n\n1. Attacker sends request with `X-Real-IP: 10.0.0.1` (spoofed internal IP)\n2. `BalancerForward` handler executes at line 282\n3. `c.Request().Header.Add(\"X-Real-IP\", c.IP())` APPENDS the real IP as a second header\n4. Upstream server receives: `X-Real-IP: 10.0.0.1` AND `X-Real-IP: <real-attacker-ip>`\n5. Most HTTP servers (nginx, Node.js, Apache) read the FIRST value\n6. Upstream uses `10.0.0.1` for all IP-dependent logic\n\n## Impact\n\n- **Rate limit bypass:** IP-based rate limiting at the upstream uses the spoofed IP, allowing unlimited requests\n- **IP ACL bypass:** Internal IP allowlists (e.g., admin panels restricted to `10.0.0.0/8`) can be bypassed\n- **Audit log poisoning:** Security logs record the spoofed IP, making incident investigation unreliable\n- **Geolocation bypass:** IP-based geofencing or region restrictions are circumvented\n\n## Fix\n\nReplace `Header.Add()` with `Header.Set()` at line 282:\n\n```go\nc.Request().Header.Set(\"X-Real-IP\", c.IP())\n```\n\n`Header.Set()` replaces any existing header value, ensuring only the real client IP is forwarded.","format":"markdown","source":"ghsa"},{"lang":"en","text":"GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward in github.com/gofiber/fiber","format":"markdown","source":"go"},{"lang":"es","text":"Fiber es un framework web inspirado en Express escrito en Go. Antes de las versiones 3.3.0 y 2.52.14, el asistente de proxy BalancerForward en middleware/proxy/proxy.go utiliza Header.Add() en lugar de Header.Set() al inyectar X-Real-IP, permitiendo que un primer valor de X-Real-IP proporcionado por el atacante sea reenviado a los servidores ascendentes para registro, limitación de velocidad y control de acceso. Este problema está solucionado en las versiones 3.3.0 y 2.52.14.","source":"nvd"}],"published":"2026-07-02T13:50:45.000Z","modified":"2026-10-25T17:10:00.197Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-290"],"affected":[{"ranges":[{"version":">= 3.0.0-beta.2, < 3.3.0","status":"affected"},{"version":"< 2.52.14","status":"affected"}],"vendor":"gofiber","product":"fiber","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"Go","package":"github.com/gofiber/fiber/v3","purl":"pkg:golang/github.com/gofiber/fiber/v3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.52.14"}],"ecosystem":"Go","package":"github.com/gofiber/fiber/v2","purl":"pkg:golang/github.com/gofiber/fiber/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"Go","package":"github.com/gofiber/fiber/v3","purl":"pkg:golang/github.com/gofiber/fiber/v3","source":"go"},{"ranges":[{"status":"affected","fixed":"2.52.14"},{"status":"affected","introduced":"3.0.0","fixed":"3.3.0"}],"vendor":"gofiber","product":"fiber","cpe":"cpe:2.3:a:gofiber:fiber:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/gofiber/fiber/security/advisories/GHSA-gcfq-8gqf-4876","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gofiber/fiber/pull/4260","tags":["fix","issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gofiber/fiber/pull/4495","tags":["issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gofiber/fiber/commit/1403cc8292da3220e9316960b4030cc722a0f396","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gofiber/fiber/commit/33c9501288ab47a429c8b5e701493f0c3c0af37d","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gofiber/fiber/releases/tag/v2.52.14","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/gofiber/fiber/releases/tag/v3.3.0","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45045","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/gofiber/fiber","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-07-09T13:19:42.395Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-45045","url":"https://www.cve.org/CVERecord?id=CVE-2026-45045","licence":"CVE Terms of Use","modified":"2026-07-09T13:20:08.367Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-gcfq-8gqf-4876","url":"https://github.com/advisories/GHSA-gcfq-8gqf-4876","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:52.054Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5887","url":"https://pkg.go.dev/vuln/GO-2026-5887","licence":"CC-BY-4.0","modified":"2026-07-24T19:00:26.866Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-45045","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45045","licence":"Public domain","modified":"2026-10-25T17:10:00.197Z"}],"updatedAt":"2026-11-25T22:59:27.412Z","epss":{"score":0.00339,"percentile":0.29381,"date":"2026-12-01T12:00:22.000Z"}}