Skip to content

fix(backend): Stop verifying ES256 tokens - #11105

Merged
nikosdouvlis merged 16 commits into
mainfrom
nikos/backend-drop-es256
Dec 3, 2026
Merged

nikosdouvlis merged 16 commits into
mainfrom
nikos/backend-drop-es256

Conversation

@nikosdouvlis

@nikosdouvlis nikosdouvlis commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #11107. @clerk/backend removes the ES256 support added in 3.34.0 and stops accepting ES256 tokens, and a configured jwtKey is always used to verify. Multi-key JWKS, composite kids and kid-based key selection from #11036 stay.

 loadVerificationKey
-  jwtKey set → RSA PEM or P-256 JWK; if it can't verify the token alg and secretKey is set → JWKS by kid
+  jwtKey set → RSA PEM, always used
   no jwtKey  → JWKS by kid

 verifyJwt algorithms
-  RS256 | RS384 | RS512 | ES256
+  RS256 | RS384 | RS512

Evidence

  • Before: an ES256 token verified against an EC key from the JWKS.
    After: verify.test.ts "rejects an ES256 session JWT with token-invalid-algorithm" passes, and an RS256 token still verifies while the JWKS lists an EC key.
  • A pinned jwtKey makes 0 JWKS requests when the signature check fails.

Merge Danger

Door: two-way

A revert restores ES256. An ES256 session cookie is signed out on this version, not refreshed through a handshake.

Blast Radius: verification

  • Apps on an instance that signs with ES256 lose their sessions.
  • A jwtKey set to a P-256 key stops working.
  • signJwt / verifyJwt throw for ES256.
  • A configured jwtKey never calls the network, which matches the behavior before 3.34.

@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 3, 2026 3:24pm UTC
mosaic-docs Ready Ready Preview Dec 3, 2026 3:24pm UTC
swingset Ready Ready Preview Dec 3, 2026 3:24pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes remove ES256 from the supported JWT algorithms and restrict key import types to RSA. A configured jwtKey is passed to verification without checking its compatibility against the token algorithm or falling back to JWKS; without a configured key, verification loads a remote JWK. Verification entry points no longer pass the token algorithm to key loading. Tests and the release changeset reflect these changes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: dominic-clerk, wobsoriano

Merge Risk: Low · up to 43e0d

This change removes ES256 support from the backend SDK and always uses a configured jwtKey as an RSA key. Any app still using ES256-signed sessions or a P-256 jwtKey will see those sessions rejected and users signed out. Confirm that no instances still use ES256 before releasing. Otherwise the change is well tested and easy to reverse.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the backend stops verifying ES256 tokens. The changeset removes ES256 support, the algorithm list drops ES256, and tests now expect ES256 to be rejected. The title us…
Description check Passed The description states that @clerk/backend removes ES256 support and that a configured jwtKey is always used for verification. It also lists the before and after verification rules, test evidence, and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: the backend stops verifying ES256 tokens. The changeset removes ES256 support, the algorithm list drops ES256, and tests now expect ES256 to be rejected. The title uses the fix(backend) prefix and is concise, so it matches the changeset.

Full details: Description check

Explanation

The description states that @clerk/backend removes ES256 support and that a configured jwtKey is always used for verification. It also lists the before and after verification rules, test evidence, and merge risks. These match the changed files in the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 72f06a5 and 43e0d90.

Files selected for processing: 5

  • .changeset/backend-rs256-only.md
  • packages/backend/src/fixtures/index.ts
  • packages/backend/src/tokens/__tests__/keys.test.ts
  • packages/backend/src/tokens/__tests__/verify.test.ts
  • packages/backend/src/tokens/keys.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 8 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ce41c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/swingset Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@11105

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@11105

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@11105

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@11105

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@11105

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@11105

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@11105

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@11105

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@11105

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@11105

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@11105

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@11105

@clerk/express

npm i https://pkg.pr.new/@clerk/express@11105

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@11105

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@11105

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@11105

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@11105

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@11105

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@11105

@clerk/react

npm i https://pkg.pr.new/@clerk/react@11105

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@11105

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@11105

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@11105

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@11105

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@11105

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@11105

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@11105

commit: 43e0d90

@nikosdouvlis
nikosdouvlis marked this pull request as ready for review December 3, 2026 13:50
@blacksmith-sh

blacksmith-sh Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Matches ES256 session token is rejected

Tested on 7ce41c38 — Same ES256 session token: merge-base verified it via the JWKS, PR head returns token-invalid-algorithm.

Merge-base

ES256 token verify

This PR 7ce41c38

ES256 token verify

Also checked · 3 match

Matches RS256 still verifies with an EC key in the JWKS
Matches Configured jwtKey never fetches the JWKS
Matches P-256 jwtKey and ES256 signJwt stop working

Proof on 43e0d908 (from 7ce41c38) · mocked: Backend API /v1/jwks (Loopback JWKS fixture serves generated EC and RSA test keys and counts requests) · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@nikosdouvlis nikosdouvlis changed the title fix(backend): Stop verifying ES256 tokens fix(backend): Accept RSA jwtKey of any size and stop verifying ES256 tokens Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-12-03T15:28:52.850Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 43e0d90.

@vercel
vercel Bot temporarily deployed to Preview – clerk-js-sandbox December 3, 2026 14:17 Inactive
@nikosdouvlis nikosdouvlis changed the title fix(backend): Accept RSA jwtKey of any size and stop verifying ES256 tokens fix(backend): Stop verifying ES256 tokens Dec 3, 2026
@nikosdouvlis
nikosdouvlis changed the base branch from main to nikos/backend-jwt-key-any-size December 3, 2026 14:17

@maxmil maxmil left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice to see we've actually simplified things.

Minor nitpik: Not sure we need to prove we can verify RS384 and RS512 as these are not in spec

Small wording error in the PR body: it says a P-256 jwtKey fails as token-invalid-signature. It actually fails as token-verification-failed ("Invalid key type"). Either way the user is signed out.

# Conflicts:
#	packages/backend/src/tokens/__tests__/keys.test.ts
#	packages/backend/src/tokens/__tests__/verify.test.ts
#	packages/backend/src/tokens/keys.ts
@nikosdouvlis
nikosdouvlis merged commit 067e582 into main Dec 3, 2026
63 checks passed
@nikosdouvlis
nikosdouvlis deleted the nikos/backend-drop-es256 branch December 3, 2026 15:34

This branch was successfully deployed

2 active deployments
Preview – swingset — 43e0d908 Deployed Dec 3, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 43e0d908 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants