Repository navigation
Conversation
oliverlaz
marked this pull request as ready for review
November 25, 2026 12:39
mogita
reviewed
Nov 27, 2026
…525] The backend decodes JWT claims with Go's encoding/json, which matches names case-insensitively with Unicode simple folding and lets the last matching key win, so a custom claim such as USER_ID or uſer_id could replace or blank the user_id (a blank one is a server token). Reject custom claims that are another spelling of a claim the backend reads, reserve egress, and require a custom iat to be a positive whole Unix timestamp that is not in the future (a missing iat skips per-user token revocation). Also put user_id last in the payload.
mogita
approved these changes
Nov 27, 2026
This branch has not been deployed
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.
Ticket
https://linear.app/stream/issue/SEC-2525/sec-13-jwt-custom-claim-overwrite-server-true-escalation-go-node-php
Why
The backend treats a JWT as a server token when its
user_idis empty; theserverclaim itself is ignored. User-token helpers let caller-supplied custom claims overwriteuser_id(or, in Node, accepted an emptyuser_id), so a custom claim such asuser_id: ""could mint a token with full API access. This matters when an app forwards untrusted input into custom claims.Behavior (same across Go, Node and PHP; the Rust SDK already does this)
user_idcomes only from the user ID argument and must be non-empty.user_idorserverin custom claims is rejected with an error.exp; a customexp/iatis kept when no expiration is given.role,call_cidsandchannel_cidsstay allowed in custom claims (documented usage relies on them).Compatibility
Callers that put
user_idorserverin custom claims, or pass an emptyuser_id, now get an error instead of a token. Neither is a legitimate use.Changes
src/Auth/JWTGenerator.php:generateUserTokenthrowsStreamExceptionfor reserved claims.src/Client.php: docblock forcreateUserToken.tests/ClientTest.php: tests for reserved claims andexpprecedence.Testing
make lintandmake test-uniton PHP 8.1 and 8.5.