-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Undefined behavior when multiple JWTs are provided using different methods #11796
Comments
Can I work on this? |
Hi @mikeholler, Thank you for reporting this! Indeed the documentation could be a little bit clearer when it comes to how multiple JWTs are handled. We should probably pull all of this info into one place but just to quickly answer your question: Kong rejects requests with multiple different JWT tokens. Sending a request with more than one (but different) JWTs will results in: 401 with error message: This is desired behaviour since otherwise it introduces a security issue known as JWT smuggling. If kong proxies a request with multiple tokens when only some of them are valid the upstream can assume that all of the passed tokens are correct and grant undeserved privileges. When it comes to the order of lookup it goes like this:
It's documented but in the code: https://github.com/Kong/kong/blob/master/kong/plugins/jwt/handler.lua#L22 Saying all this I think we could bring all of this info together and explicitly state the order of jwt lookup places in the docs as well as mention what happens when multiple tokens are provided (i.e. error is returned: I'll notify the docs team to make appropriate changes. Please let me know if there's anything else you need help with :) |
Also @Atharva1723 Thank you so much for your interest but I don't think this needs fixing - other than improving the docs |
Thanks @nowNick, this is exactly the information I was looking for. Token smuggling as a concern makes a lot of sense to me, and I'll be glad to add that information to our documentation. |
That's great to hear @mikeholler . I'm going to close this issue then but feel free to reopen it if you need anything else related to it. |
Is there an existing issue for this?
Kong version (
$ kong version
)3.4.2
Current Behavior
The behavior of supplying two JWTs in one request is completely undefined in documentation.
Expected Behavior
There should be well-defined and deterministic behavior around requests that include more than one JWT.
Steps To Reproduce
The Kong JWT plugin describes three ways to provide JWTs: a cookie, a query string parameter, or a header. Unfortunately, it doesn't describe what happens when multiple are provided.
Take the following config:
What happens when all locations are populated by a valid (but different) token? What is the priority on the order they are resolved and tested? What if an invalid token is found? Does it go through invalid tokens until it finds one invalid token (or runs out) or does it fail fast on the first invalid token?
We'd like to include this documentation in our product, but as it isn't documented in Kong, this is challenging, and the contract may change at any point in time as it is not documented.
Anything else?
No response
The text was updated successfully, but these errors were encountered: