fix: treat TokenSource JWTs without exp as expired - #1008
Open
SashaMIT wants to merge 1 commit into
Open
Conversation
CachingTokenSource.hasValidToken treated a missing exp as still valid, so TokenSourceCached never refetched. Require exp and keep nbf optional, matching client-sdk-js#2057.
SashaMIT
requested review from
MaxHeimbrock,
davidliu and
xianshijing-lk
as code owners
August 24, 2026 14:07
🦋 Changeset detectedLatest commit: 69d8699 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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.
Problem
TokenSourceResponse.hasValidTokentreated a missingexpas still valid:TokenSourceCachedthen keeps serving that response. A JWT with noexpstays cached forever.nbfis already optional (checked only when present). That part is correct. The hole is the suffix-side missingexp.This is the Android cache counterpart of livekit/client-sdk-js#2057. Same class as the server-sdk
TokenVerifierlanguage-splits (protocol#1706, python-sdks#779, node-sdks#710, server-sdk-ruby#97, server-sdk-kotlin#170). Those requireexpon verify. This helper decides whether to refetch.Fix
Require
exp. Keepnbfoptional. Leave the existing one-minute after-expiry tolerance unchanged.Threat-model: the cached participant token is already on the device. The attacker does not need host or TokenSource authority. A token that omits
expnever triggers a refetch. The server may still reject the JWT; the client never goes back to the token source.Test plan
./gradlew :livekit-android-test:testDebugUnitTest --tests io.livekit.android.token.CachingTokenSourceTest(7/7)expiresAt != null &&failstokenWithoutExpIsInvalid./gradlew spotlessApplyMade with Cursor