Skip to content

Consolidate access-token storage to the server-side session - #115

Closed
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
nickcollisson/sec-1348-remove-workos-access-token-cookie-channel
Closed

Consolidate access-token storage to the server-side session#115
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
nickcollisson/sec-1348-remove-workos-access-token-cookie-channel

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The client TokenStore (src/client/tokenStore.ts) read a JavaScript-readable workos-access-token cookie and adopted it as the session bearer token. This change removes that client-readable cookie channel and sources the token from the server-side session.

Please review before merging.

The client TokenStore read a plain, JavaScript-readable workos-access-token cookie and adopted its value as the session bearer access token, with no binding to the authenticated session. No server component in this SDK (or in @workos/authkit-session) ever writes this cookie, so it was a dead input channel: an attacker able to write a cookie on the app's registrable domain could plant their own valid token and cause the victim's client-side API calls to authenticate as the attacker. A Path mismatch in the consume-and-delete logic also let a Path=/ plant persist across page loads.

Remove the cookie read/consume/delete paths entirely. Tokens are now sourced only from the session-bound server RPCs, which are the only legitimate source. Add a regression test asserting a planted cookie is ignored.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from Linear User

Please work on ticket "AuthKit TanStack client token store adopts attacker-plantable workos-access-token cookie as the session access token (persistent token fixation via cookie injection)" (SEC-1348)

@playbook:playbook-b588614117c7477a9b9729928385384f

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

SEC-1348

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the client-readable access-token cookie channel. The main changes are:

  • Initializes the client token store without reading document.cookie.
  • Uses session-bound server actions as the only access-token source.
  • Updates refresh scheduling coverage to use server action results.
  • Adds a test proving that a planted access-token cookie is ignored.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • Fresh token stores already acquire tokens through the session-bound server action.
  • Successful RPC acquisition still schedules token refreshes.
  • The new test covers the reported cookie-substitution path.

Important Files Changed

Filename Overview
src/client/tokenStore.ts Removes cookie-based token initialization and retrieval while preserving session-bound acquisition and refresh scheduling.
src/client/tokenStore.spec.ts Moves refresh setup to the server action path and verifies that planted access-token cookies are ignored.

Reviews (1): Last reviewed commit: "Remove client-readable access-token cook..." | Re-trigger Greptile

@devin-ai-integration
devin-ai-integration Bot deleted the nickcollisson/sec-1348-remove-workos-access-token-cookie-channel branch July 27, 2026 16:15
@devin-ai-integration devin-ai-integration Bot changed the title Remove client-readable access-token cookie channel Consolidate access-token storage to the server-side session Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

0 participants