Skip to content

fix(session): Reject non-user access tokens in session cookies - #16

Merged
gjtorikian merged 1 commit into
mainfrom
fix/session-user-access-token-claims
Nov 6, 2026
Merged

gjtorikian merged 1 commit into
mainfrom
fix/session-user-access-token-claims

Conversation

@m0tzy

@m0tzy m0tzy commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Summary

SessionCookie.authenticate() and Session.authenticateWithSessionCookie() now accept only user access tokens. Other tokens signed by the same environment key (agent and widget tokens) return INVALID_JWT. This matches workos-kotlin and the other WorkOS SDKs.

JwksVerifier.isValid checks the token after signature/exp verification and before the optional issuers check:

claims.getClaim("sid") is String &&
  claims.getClaim("auth_time") is Number &&
  (subProfile == null || subProfile == "user") &&
  claims.getClaim("sub_type") == null

User access tokens always include sid and auth_time, and they omit sub_profile or set it to "user". The signedJwt test helper now sets both by default. The new rejection test fails without the change.

Link to Devin session: https://app.devin.ai/sessions/7e123fc2545a49c282b043a4abd58f70
Open in Devin Desktop: https://app.devin.ai/desktop/session/7e123fc2545a49c282b043a4abd58f70?variant=devin
Requested by: @m0tzy

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Original prompt from madison.packer

What's the fix here? https://linear.app/workos/issue/VULN-4839/lt-app26-10-user-vs-agent-jwt-type-confusion

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Devin Review

🟢 Devin Review found nothing to fix · View findings

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge.

Summary

Session-cookie authentication now rejects non-user tokens after signature and time checks, before the optional issuer check.

  • Session cookies accept only user access tokens.

Reviews (1) · Last reviewed commit: "fix(session): Reject non-user access tok..." · Reviewed by Greptile

@gjtorikian

Copy link
Copy Markdown
Collaborator

thank you!

@gjtorikian
gjtorikian merged commit 3d888d9 into main Nov 6, 2026
9 checks passed
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.

2 participants