fix(auth0-express): reject userinfo (@) in inferred base URL host - #45
Open
frederikprijck wants to merge 1 commit into
Open
fix(auth0-express): reject userinfo (@) in inferred base URL host#45frederikprijck wants to merge 1 commit into
frederikprijck wants to merge 1 commit into
Conversation
A Host or X-Forwarded-Host header like `legitimate.com@evil.com` is parsed by the URL constructor as userinfo `legitimate.com` with origin `evil.com`. In dynamic (undefined) base-URL mode this value is trusted directly, and previously nothing rejected the userinfo, letting an attacker smuggle an attacker-controlled origin past the origin checks that consume the inferred base URL. Reject any inferred host containing `@`. Hardens the origin checks in `createRouteUrl`/`toSafeRedirect` as defense-in-depth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens dynamic base-URL inference against Host-header userinfo injection, flagged in a security review.
When
appBaseUrlisundefined(dynamic mode),inferBaseUrlFromRequestbuilds the base URL from theHost(or trustedX-Forwarded-Host) header. A header likelegitimate.com@evil.comis parsed by the URL constructor as userinfolegitimate.comwith originevil.com. Since the inferred value feeds the origin checks increateRouteUrl/toSafeRedirect, a smuggled userinfo component could confuse origin determination.This change rejects any inferred host containing
@, returningnull(which surfaces as anInvalidConfigurationErrorinresolveAppBaseUrl).Context / severity
This is defense-in-depth, not a confirmed exploitable open redirect:
Hostheader is already trusted by design, and theredirect_uriis derived from the same inferred base URL — so Auth0's registered-callback-URL validation independently rejects the poisoned URI. The@trick grants no extra capability over simply sendingHost: evil.com.Still, rejecting
@is cheap and correct — the existing spec test already earmarked this as future hardening.Changes
app-base-url.ts: reject inferred hosts containing@.app-base-url.spec.ts: flip the previously-documented "current behaviour" test to assertnull, and add anX-Forwarded-Hostcase.Testing
vitest run— 207 passednpm run lint— clean🤖 Generated with Claude Code