Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: null pointer exception in GetTokenIDAndSubjectFromToken #704

Open
2 tasks done
gczuczy opened this issue Jan 31, 2025 · 1 comment
Open
2 tasks done

[Bug]: null pointer exception in GetTokenIDAndSubjectFromToken #704

gczuczy opened this issue Jan 31, 2025 · 1 comment
Labels
auth bug Something isn't working good first issue Good for newcomers

Comments

@gczuczy
Copy link

gczuczy commented Jan 31, 2025

Preflight Checklist

  • I could not find a solution in the documentation, the existing issues or discussions
  • I have joined the ZITADEL chat

Version

3.34.1 and master branch

Describe the problem caused by this bug

In pkg/op/exchange_token.go:
From L309-313:

tokenIDOrToken, subject, accessTokenClaims, ok = getTokenIDAndClaims(ctx, exchanger, token)
		if !ok {
			break
		}
		claims = accessTokenClaims.Claims

And the getTokenIDAndClaims function has a return case at L424:

return splitToken[0], splitToken[1], nil, true

When this codepath is hit, ok is true, then the accessTokenClaims is a nil point, which is accessed.

Second bug: this usecase is not covered by unit tests.

To reproduce

Try to do a token exchange which is hitting this codepath (user initiates a client credential grant flow, then tries to exchange the token to have the audience match the resource provider it is trying to access).

Screenshots

No response

Expected behavior

The token exchange working properly.

Additional Context

Discord gladly has thrown some errors which thankfully made me unable to join.

@gczuczy gczuczy added the bug Something isn't working label Jan 31, 2025
@muhlemmer muhlemmer moved this to 🐛 Bugs/Small Issues in Product Management Feb 3, 2025
@muhlemmer muhlemmer added auth good first issue Good for newcomers labels Feb 3, 2025
@muhlemmer
Copy link
Collaborator

We are open for a PR. At Zitadel we do not use this implementation, so its unlikely any staff will work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth bug Something isn't working good first issue Good for newcomers
Projects
Status: 🐛 Bugs/Small Issues
Development

No branches or pull requests

2 participants