CVE-2026-45045
JSON

5.3medium

Fiber: X-Real-IP Spoofing via Header.Add() in BalancerForward

Severity
5.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.34% (higher than 29% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-gcfq-8gqf-4876GO-2026-5887

Description

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.

Affected

Product or packageVersionsReported by
gofiber fiber>= 3.0.0-beta.2, < 3.3.0, < 2.52.14, before 2.52.14, from 3.0.0 before 3.3.0CVE List, NVD
github.com/gofiber/fiber/v3 (Go)before 3.3.0GitHub Advisory Database, Go Vulnerability Database
github.com/gofiber/fiber/v2 (Go)before 2.52.14GitHub Advisory Database

All scores

GitHub_M5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N

Classification

CWE-290

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

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.

Go Vulnerability Database

GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward in github.com/gofiber/fiber

NVD (es)

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.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-45045 changed 2026-07-09CVE Terms of Use
GitHub Advisory DatabaseGHSA-gcfq-8gqf-4876 changed 2026-09-10CC-BY-4.0
Go Vulnerability DatabaseGO-2026-5887 changed 2026-07-24CC-BY-4.0
NVDCVE-2026-45045 changed 2026-10-25Public domain