Skip to content
New issue

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

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

Already on GitHub? # to your account

question: panic on incorrect segments in jwt token could lead to denail of service? #2

Open
c-nv-s opened this issue Jul 2, 2023 · 1 comment

Comments

@c-nv-s
Copy link

c-nv-s commented Jul 2, 2023

I encountered this error when trying to figure out if there was a way to setup middleware for validating a cookie

panic: token contains an invalid number of segments  

I understand that in the example given in the docs it falls on the user to manually check this (https://docs.authorizer.dev/authorizer-go/example)

if len(tokenSplit) < 2 || tokenSplit[1] == "" {
			// unauthorized
			c.AbortWithStatusJSON(401, "unauthorized")
			return
		}

However, if a user doesn't check this then why should their application panic instead of logging that the jwt issued is not a valid format/malformed instead of causing the user to have to restart their service.
surely this gives bad actors an easy way to achieve denial of service by just issuing badly formed JWT tokens?

@lakhansamani
Copy link
Contributor

@c-nv-s thanks for reporting it I am looking into it and sorry for the delay!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants