-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jwt_decode_2(): Security vulnerability for alg:none
This function had faulty logic based on some assumptions that it could trust the JWT in that if it was alg:none, it would not run the callback. The assumption would allow an attacker to modify the JWT header and body and trick the function into returning without having retrieved a key from the cb. The caller of jwt_decode_2 has no real way to know that their cb was never run. New logic runs the callback ALWAYS. This way the key_provider is guaranteed to have been called if jwt_decode_2 returns with a successful jwt_t object and 0 return code. As an aside, making this change found that some of our test cases were assuming that you could call jwt_decode_2 with key_provider of NULL. This doesn't make much sense, considering there's no way to pass a key without a key_provider. In this instance, if passed a JWT with alg:none, this was fine. If called with any other alg type, the code would attempt to run the NULL key_provider and produce a SEGV. RESOLUTION: - jwt_decode_2 will always run the key_provider assuming there was not a previous error (jwt_decode_2() == means it ran). - Always check key_provider for NULL before using it - If no key_provider, but JWT had alg!=none, processing fails NOTES: - jwt_decode() and jwt_decode_2() are being deprecated in favor more robust functionality. Signed-off-by: Ben Collins <[email protected]>
- Loading branch information
1 parent
2863d88
commit 096082e
Showing
2 changed files
with
177 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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