Skip to content

fix(op): guard against nil claims for opaque access tokens in token exchange - #959

Open
ChrisJr404 wants to merge 1 commit into
zitadel:mainfrom
ChrisJr404:fix-token-exchange-nil-claims
Open

fix(op): guard against nil claims for opaque access tokens in token exchange#959
ChrisJr404 wants to merge 1 commit into
zitadel:mainfrom
ChrisJr404:fix-token-exchange-nil-claims

Conversation

@ChrisJr404

Copy link
Copy Markdown

Fixes #704.

Doing a token exchange with an opaque access token panics. When the token is an encrypted tokenID:subject string rather than a JWT, getTokenIDAndClaims returns nil claims with ok true, and GetTokenIDAndSubjectFromToken then dereferences that nil pointer on accessTokenClaims.Claims.

I added a nil guard so opaque tokens come back with empty claims (there are no JWT claims to read in that case), and a test for the opaque path since, as the issue mentions, it wasn't covered before.

…xchange

Exchanging an opaque access token (an encrypted tokenID:subject string)
panicked, because getTokenIDAndClaims returns nil claims with ok true and
the caller dereferenced them unconditionally. Skip the dereference when
there are no claims and add a test covering that path.
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.

[Bug]: null pointer exception in GetTokenIDAndSubjectFromToken

1 participant