fix: use fixed expiry for asymmetric JWT generation#4752
Closed
7ttp wants to merge 1 commit intosupabase:developfrom
Closed
fix: use fixed expiry for asymmetric JWT generation#47527ttp wants to merge 1 commit intosupabase:developfrom
7ttp wants to merge 1 commit intosupabase:developfrom
Conversation
Contributor
Author
sweatybridge
requested changes
Jan 24, 2026
Contributor
sweatybridge
left a comment
There was a problem hiding this comment.
This ensures the JWT payload remains identical across multiple generations.
We don't want to encourage users to rely on this behaviour. Each JWT should be validated against the JWT secret using one of the well known libraries. Direct string comparison is almost always a bad idea.
That said, I agree the current behaviour of status command is very misleading. It should read the last used JWT from the running container instead.
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
Running
supabase status -o envmultiple times produces differentSERVICE_ROLE_KEYvalues on each invocation when using asymmetric signing keys.This breaks workflows where the service role key needs to be stored in a vault or used consistently across multiple command runs.
Problem
When
LoadConfig()is called (which happens on everysupabase statusrun), it regenerates JWT keys.For asymmetric keys, the expiry was set using
time.Now().Add(10 years),causing the JWT payload to have a different expiry timestamp on each generation:
exp: 2036-01-23 19:37:15exp: 2036-01-23 19:37:16(1 second later)Different expiry → Different
JWTpayload → DifferentSERVICE_ROLE_KEYSolution
Use the same fixed expiry constant (
defaultJwtExpiry = 1983812996, expires Nov 2032) that symmetric keys already use.This ensures the JWT payload remains identical across multiple generations.
This aligns asymmetric key behavior with symmetric keys (line 35)
Related