GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward
Published 2 Jul 2026 · Updated 10 Sept 2026
Is your project on an affected github.com/gofiber/fiber/v3?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- <3.3.0
- Fixed in
- 3.3.0
go get github.com/gofiber/fiber/v3@v3.3.0- Affected
- <2.52.14
- Fixed in
- 2.52.14
go get github.com/gofiber/fiber/v2@v2.52.14Details
Summary
The 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.
Vulnerable Code
File: middleware/proxy/proxy.go, lines 270-285
func BalancerForward(servers []string, clients ...*fasthttp.Client) fiber.Handler {
r := &roundrobin{
current: 0,
pool: servers,
}
return func(c fiber.Ctx) error {
server := r.get()
if !strings.HasPrefix(server, "http") {
server = "http://" + server
}
c.Request().Header.Add("X-Real-IP", c.IP()) // line 282: Add, not Set
return Do(c, server+c.OriginalURL(), clients...)
}
}Data Flow
1. Attacker sends request with X-Real-IP: 10.0.0.1 (spoofed internal IP)
2. BalancerForward handler executes at line 282
3. c.Request().Header.Add("X-Real-IP", c.IP()) APPENDS the real IP as a second header
4. Upstream server receives: X-Real-IP: 10.0.0.1 AND X-Real-IP: <real-attacker-ip>
5. Most HTTP servers (nginx, Node.js, Apache) read the FIRST value
6. Upstream uses 10.0.0.1 for all IP-dependent logic
Impact
- Rate limit bypass: IP-based rate limiting at the upstream uses the spoofed IP, allowing unlimited requests
- IP ACL bypass: Internal IP allowlists (e.g., admin panels restricted to
10.0.0.0/8) can be bypassed - Audit log poisoning: Security logs record the spoofed IP, making incident investigation unreliable
- Geolocation bypass: IP-based geofencing or region restrictions are circumvented
Fix
Replace Header.Add() with Header.Set() at line 282:
c.Request().Header.Set("X-Real-IP", c.IP())Header.Set() replaces any existing header value, ensuring only the real client IP is forwarded.
Is GHSA-gcfq-8gqf-4876 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/gofiber/fiber/v3, and gives you the command that fixes it.
More advisories for github.com/gofiber/fiber/v3
- LowCVE-2026-30246Fiber: Cache middleware key generator ignores query string in github.com/gofiber/fiber · 24 Jul 2026
- LowCVE-2026-42554Fiber vulnerable to XSS in AutoFormat Content Negotiation in github.com/gofiber/fiber · 24 Jul 2026
- LowCVE-2026-44332GoFiber Vulnerable to Username Enumeration via Timing Oracle in BasicAuth Default Authorizer in github.com/gofiber/fiber · 24 Jul 2026
- LowCVE-2026-53624GoFiber never set HSTS header in helmet middleware due to incorrect protocol check in github.com/gofiber/fiber · 24 Jul 2026
- MediumCVE-2026-44332GoFiber Vulnerable to Username Enumeration via Timing Oracle in BasicAuth Default Authorizer · 2 Jul 2026
- MediumCVE-2026-42554Fiber vulnerable to XSS in AutoFormat Content Negotiation · 5 May 2026
References
- Linkgithub.com/gofiber/fiber/security/advisories/GHSA-gcfq-8gqf-4876
- Advisorynvd.nist.gov/vuln/detail/CVE-2026-45045
- Linkgithub.com/gofiber/fiber/pull/4260
- Linkgithub.com/gofiber/fiber/pull/4495
- Linkgithub.com/gofiber/fiber/commit/1403cc8292da3220e9316960b4030cc722a0f396
- Linkgithub.com/gofiber/fiber/commit/33c9501288ab47a429c8b5e701493f0c3c0af37d
- Packagegithub.com/gofiber/fiber
- Linkgithub.com/gofiber/fiber/releases/tag/v2.52.14
- Linkgithub.com/gofiber/fiber/releases/tag/v3.3.0
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.