Lack of data validation In github.com/gofiber/fiber/v2
Description
Fiber has a Denial of Service Vulnerability via Route Parameter Overflow A denial of service vulnerability exists in Fiber v2 and v3 that allows remote attackers to crash the application by sending requests to routes with more than 30 parameters. The vulnerability results from missing validation during route registration combined with an unbounded array write during request matching.
Affected Versions
Fiber v3.0.0-rc.3 and earlier v3 releases
Fiber v2.52.10 and potentially all v2 releases (confirmed exploitable)
Both versions share the same vulnerable routing implementation
Vulnerability Details
Root Cause
Both Fiber v2 and v3 define a fixed-size parameter array in ctx.go:
const maxParams = 30 type DefaultCtx struct { values [maxParams]string // Fixed 30-element array // ... }
The router.go register() function accepts routes without validating parameter count. When a request matches a route exceeding 30 parameters, the code in path.go performs an unbounded write:
v3: path.go:514
v2: path.go:516
// path.go:514 - NO BOUNDS CHECKING params[paramsIterator] = path[:i]
When paramsIterator >= 30, this triggers:
panic: runtime error: index out of range [30] with length 30
Attack Scenario
Application registers route with >30 parameters (e.g., via code or dynamic routing):
app.Get("/api/:p1/:p2/:p3/.../p35", handler)
Attacker sends matching HTTP request:
curl http://target/api/v1/v2/v3/.../v35
Server crashes during request processing with runtime panic
Proof of Concept
For Fiber v3
package main import ( "fmt" "net/http" "time" "github.com/gofiber/fiber/v3" )...
Output:
Registering route: /test/:p1/:p2/:p3/:p4/:p5/:p6/:p7/:p8/:p9/:p10... ✓ Registration succeeded (NO PANIC) 🔴 Sending exploit request... Expected: panic at path.go:514 params[paramsIterator] = path[:i] panic: runtime error: index out of range [30] with length 30 ...
For Fiber v2
package main import ( "fmt" "net/http" "time" "github.com/gofiber/fiber/v2" )...
Output (v2):
Registering route: /test/:p1/:p2/:p3/:p4/:p5/:p6/:p7/:p8/:p9/:p10... ✓ Registration succeeded (NO PANIC) 🔴 Sending exploit request... Expected: panic at path.go:516 params[paramsIterator] = path[:i] panic: runtime error: index out of range [30] with length 30 ...
Impact
Exploitation Requirements
No authentication required
Single HTTP request triggers crash
Trivially scriptable for sustained DoS
Works against any route with >30 parameters
Real-World Impact
Public APIs: Remote DoS attacks on vulnerable endpoints
Microservices: Cascade failures if vulnerable service is critical
Auto-scaling: Repeated crashes prevent proper recovery
Monitoring: Log flooding and alert fatigue
Likelihood
HIGH - Exploitation requires only:
Knowledge of route structure (often public in APIs)
Standard HTTP client (curl, browser, etc.)
Single malformed request
Workarounds
Until patched, users should:
Audit Routes: Ensure all routes have ≤30 parameters
# Search for potential issues grep -r "/:.*/:.*/:.*" . | grep -v node_modules
Disable Dynamic Routing: If programmatically registering routes, validate parameter count:
paramCount := strings.Count(route, ":") if paramCount > 30 { log.Fatal("Route exceeds maxParams") }
Rate Limiting: Deploy aggressive rate limiting to mitigate DoS impact
Monitoring: Alert on panic patterns in application logs
Timeline
2024-12-24: Vulnerability discovered in v3 during PR #3962 review
2024-12-25: Proof of concept confirmed exploitability in v3
2024-12-25: Vulnerability confirmed to also exist in v2 (same root cause)
2024-12-25: Security advisory created
References
v3 Related PR: https://github.com/gofiber/fiber/pull/3962 (UpdateParam feature with defensive checks, doesn't fix root cause)
Vulnerable Code Locations:
v3: path.go:514
v2: path.go:516
Credit
Discovered by: @sixcolors (Fiber maintainer) and @TheAspectDev
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Component | Affected version | Patched versions |
|---|---|---|---|
go | 3.1.0 | ||
go | 2.52.12 |
Aliases
References