Repository navigation
fix: keep session material and open redirects out of switchToOrganization - #94
Merged
Merged
Conversation
…tion Two hardening changes to the same helper. VULN-1244: the no-returnTo branch returned refreshSession's result verbatim in data(), which serialized accessToken, sealedSession (the iron-sealed blob wrapping the refresh token) and the raw Set-Cookie string into the browser-readable single-fetch payload and SSR hydration data. Return an allowlisted projection of display-safe claims instead; the session still travels via the Set-Cookie response header only. Same invariant authkitLoader has enforced since CVE-2025-55008. VULN-1264: the returnTo branch called redirect(returnTo) raw. Run it through the package's existing sanitizeReturnPathname so a request-controlled value cannot produce an off-origin redirect. Rejected values redirect to /.
Contributor
|
gjtorikian
approved these changes
Sep 15, 2026
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.
Hardens
switchToOrganizationinsrc/auth.ts. Two findings, one function, one change.VULN-1244: session material in action data
The no-
returnTobranch returnedrefreshSession's result verbatim indata(). That serializedaccessToken,sealedSession(the iron-sealed blob that wraps the refresh token) and the rawSet-Cookiestring into the browser-readable single-fetch.datapayload and the SSR hydration HTML. Replaying just the cookie lifted from that body authenticated as the victim.Fix: return an allowlisted projection of display-safe claims (
user,sessionId,organizationId,role,roles,permissions,entitlements,featureFlags,impersonator). The session still travels via theSet-Cookieresponse header only. This is the same invariantauthkitLoaderhas enforced since CVE-2025-55008 (20102af/607caac); this branch was missed then.Allowlist rather than destructure-away so a future field added to
refreshSessiondoes not leak by default.VULN-1264: open redirect via
returnToThe
returnTobranch calledredirect(returnTo)raw.getSignInUrl/getSignUpUrlalready run the same shape of caller-supplied return target throughsanitizeReturnPathname; this sink was the inconsistency.Fix:
redirect(sanitizeReturnPathname(returnTo)). Absolute URLs, protocol-relative, backslash, CRLF, and encoded bypasses all redirect to/. Same-origin paths with query and hash pass through unchanged.Behavior change: a caller passing an absolute same-origin URL (
https://myapp.com/dashboard) asreturnTonow lands on/. Pass a pathname instead.signOut({ returnTo })is unchanged; that one is an absolute URL validated against the WorkOS dashboard allowlist.Verification
npm run typecheck,npm run lint,npm run prettier: cleannpm test: 181 passedauth.ts(8 failures) and pass with this changeRefs VULN-1244, VULN-1264. The Remix twin (VULN-1260,
authkit-remix/src/auth.ts) has the identical pattern and is not covered here.