Skip to content

fix(auth): require exp claim when verifying access tokens - #1706

Open
SashaMIT wants to merge 1 commit into
livekit:mainfrom
SashaMIT:fix/require-exp-claim
Open

fix(auth): require exp claim when verifying access tokens#1706
SashaMIT wants to merge 1 commit into
livekit:mainfrom
SashaMIT:fix/require-exp-claim

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 7, 2026

Copy link
Copy Markdown

Problem

APIKeyTokenVerifier.Verify parses with WithValidMethods / WithIssuer / WithLeeway but not WithExpirationRequired. Under golang-jwt v5, a token carrying no exp claim at all passes validation and never expires.

First-party SDKs always set exp (the Go SDK unconditionally defaults it in ToJWT), so this doesn't affect well-behaved minters — but any hand-rolled or third-party minter that forgets exp silently mints a permanent credential, and the server accepts it without complaint.

Fix

Add jwt.WithExpirationRequired() to the parse options. One line; tokens with a valid exp are unaffected.

Tests

Added token without exp is rejected to TestVerifier, using a hand-rolled jwt.MapClaims token (the Go SDK always sets exp, so the case has to be built directly). go test ./auth/ passes.

Made with Cursor

Made with Cursor

Verify() parsed with WithValidMethods/WithIssuer/WithLeeway but not
WithExpirationRequired, so a token carrying no exp claim at all passed
validation and never expired. First-party SDKs always set exp, but any
hand-rolled or third-party minter that forgets it silently mints a
permanent credential.
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 04ed682

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant