GHSA-246p-cpwv-v3jq - Echo has Rate Limiter Bypass via Spoofed X-Forwarded-For Header in Default Configuration
## Summary
When `echo.New()` is used without explicitly setting `Echo#IPExtractor`, the `RealIP()` method falls back to reading the client-supplied `X-Forwarded-For` (or `X-Real-IP`) header without any proxy-origin validation. The default `RateLimiter()` middleware derives its per-client identifier from `ctx.RealIP()`, so an attacker can rotate arbitrary values in the `X-Forwarded-For` header on each request to obtain a fresh rate-limit bucket and bypass IP-based throttling entirely.
## Affected Component
- `context.go` โ `(*Context).RealIP()` (lines 186โ208), legacy fallback branch (lines 190โ200)
- `middleware/rate_limiter.go` โ `DefaultRateLimiterConfig.IdentifierExtractor` (lines 46โ58); `RateLimiter()` (lines 71โ76)
- `echo.go` โ `New()` (lines 326โ343), `IPExtractor` left `nil` by default
## Description
### `RealIP()` unconditionally trusts `X-Forwarded-For` when `IPExtractor` is unset
`Context.RealIP()` (`context.go:186-208`) first checks `c.echo.IPExtractor`. When this field is `nil` (the default for `echo.New()`), it falls through to legacy behavior and returns the **first IP** from the `X-Forwarded-For` header โ the position an attacker has full control over:
```go
// context.go:186-200
func (c *Context) RealIP() string {
if c.echo != nil && c.echo.IPExtractor != nil {
return c.echo.IPExtractor(c.request)
}
// Fall back to legacy behavior
if ip := c.request.Header.Get(HeaderXForwardedFor); ip != "" {
i := strings.IndexAny(ip, ",")
if i > 0 {
xffip := strings.TrimSpace(ip[:i])
xffip = strings.TrimPrefix(xffip, "[")
xffip = strings.TrimSuffix(xffip, "]")
return xffip // โ attacker-controlled first IP
}
return ip
}
if ip := c.request.Header.Get(HeaderXRealIP); ip != "" {
...
return ip // โ also attacker-controlled
}
ra, _, _ := net.SplitHostPort(c.request.RemoteAddr)
return ra
}
```
### Rate limiter def
MEDIUM
Severity & confidence
Source severitymedium
Platform severitymedium
Confidencehigh
Exploitationunknown
CVSS5.3
Affected
Vendorsgithub
Productsgithub.com/labstack/echo/v5github.com/labstack/echo/v4
Reporting sources (2)
GitHub Security Advisories
NIST NVD - National Vulnerability Database
Timeline & provenance
Published2026-10-28T19:53:47
Last updated2026-10-31T20:12:43
Ingested2026-10-28T19:59:00
FreshnessNEAR-REAL-TIME
Threat typeadvisory
Recommended action
Review the advisory and upgrade affected packages to the first patched version.
Next steps
- Identify affected systems in your environment.
- Apply the vendor patch or mitigation guidance.
- Review logs for indicators described in the advisory.
- Follow the affected vendor/product to track updates.
Confidence explanation
Reported by a government or cert-grade source (CISA, NCSC, NVD, ENISA, MSRC).
Source type: vendor ยท Original: GitHub Security Advisories