{"schema_version":"1.8.0","id":"GHSA-gcfq-8gqf-4876","published":"2026-07-02T13:50:45Z","modified":"2026-08-04T22:00:24.104862276Z","aliases":["CVE-2026-45045","GO-2026-5887"],"related":["CGA-rh8r-f3g3-pxfx"],"summary":"GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward","details":"## 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.","affected":[{"package":{"name":"github.com/gofiber/fiber/v3","ecosystem":"Go","purl":"pkg:golang/github.com/gofiber/fiber/v3"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"3.3.0"}]}],"database_specific":{"last_known_affected_version_range":"<= 3.2.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-gcfq-8gqf-4876/GHSA-gcfq-8gqf-4876.json"}},{"package":{"name":"github.com/gofiber/fiber/v2","ecosystem":"Go","purl":"pkg:golang/github.com/gofiber/fiber/v2"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.52.14"}]}],"database_specific":{"last_known_affected_version_range":"<= 2.52.13","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-gcfq-8gqf-4876/GHSA-gcfq-8gqf-4876.json"}}],"references":[{"type":"WEB","url":"https://github.com/gofiber/fiber/security/advisories/GHSA-gcfq-8gqf-4876"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45045"},{"type":"WEB","url":"https://github.com/gofiber/fiber/pull/4260"},{"type":"WEB","url":"https://github.com/gofiber/fiber/pull/4495"},{"type":"WEB","url":"https://github.com/gofiber/fiber/commit/1403cc8292da3220e9316960b4030cc722a0f396"},{"type":"WEB","url":"https://github.com/gofiber/fiber/commit/33c9501288ab47a429c8b5e701493f0c3c0af37d"},{"type":"PACKAGE","url":"https://github.com/gofiber/fiber"},{"type":"WEB","url":"https://github.com/gofiber/fiber/releases/tag/v2.52.14"},{"type":"WEB","url":"https://github.com/gofiber/fiber/releases/tag/v3.3.0"}],"database_specific":{"cwe_ids":["CWE-290"],"github_reviewed":true,"github_reviewed_at":"2026-07-02T13:50:45Z","nvd_published_at":"2026-07-08T20:16:50Z","severity":"MODERATE"},"severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"}]}