[GH-ISSUE #8898] ReDoS in proxy host header validation regex (utils/url.ts) #28549

Open
opened 2026-04-17 20:00:04 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @alavesa on GitHub (Apr 1, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8898

The hostnameRegex in validateProxyHeader uses nested quantifiers: ([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? repeated via the outer group. This can trigger catastrophic backtracking on crafted x-forwarded-host header values (e.g., a long string ending in -).

Impact: An attacker sending malicious x-forwarded-host headers could cause CPU exhaustion.

Found by PatchPilots security audit.

Originally created by @alavesa on GitHub (Apr 1, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8898 The `hostnameRegex` in `validateProxyHeader` uses nested quantifiers: `([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?` repeated via the outer group. This can trigger catastrophic backtracking on crafted `x-forwarded-host` header values (e.g., a long string ending in `-`). **Impact:** An attacker sending malicious `x-forwarded-host` headers could cause CPU exhaustion. Found by [PatchPilots](https://github.com/alavesa/patchpilots) security audit.
GiteaMirror added the securitybug labels 2026-04-17 20:00:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28549