GHSA-gcfq-8gqf-4876

Suggest an improvement
Source
https://github.com/advisories/GHSA-gcfq-8gqf-4876
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-gcfq-8gqf-4876/GHSA-gcfq-8gqf-4876.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-gcfq-8gqf-4876
Aliases
Downstream
CGA (4)
MINI (4)
Published
2026-07-02T13:50:45Z
Modified
2026-09-10T03:50:52Z
Severity
  • 5.3 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N CVSS Calculator
Summary
GoFiber Vulnerable to X-Real-IP Spoofing via Header.Add() in BalancerForward
Details

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.

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"
}
References

Affected packages

Go / github.com/gofiber/fiber/v3

Package

Name
github.com/gofiber/fiber/v3
View open source insights on deps.dev
Purl
pkg:golang/github.com/gofiber/fiber/v3

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
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"

Go / github.com/gofiber/fiber/v2

Package

Name
github.com/gofiber/fiber/v2
View open source insights on deps.dev
Purl
pkg:golang/github.com/gofiber/fiber/v2

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
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"