Repository navigation
Conversation
_Config.decode_algorithms appended this application's encode algorithm to the list object stored in app.config["JWT_DECODE_ALGORITHMS"] instead of to a copy of it. That list is held by reference, and app.config.from_object() copies attributes by reference, so applications built from a common config object share a single list. Appending therefore added the algorithm of whichever application touched the property first to the algorithms every other application accepts. For example an application configured with JWT_DECODE_ALGORITHMS = ["RS256"] and JWT_ALGORITHM = "RS256" accepts HS256 tokens once an application sharing that config object encodes with HS256. The widening is permanent: once the algorithm is in the list the "not in" test is false from then on, so resetting JWT_DECODE_ALGORITHMS no longer restores the restriction. Copy the configured list before appending. The behaviour that test_missing_algorithm_in_decode_algorithms pins is unchanged: the encode algorithm is still returned by the property, it is just no longer written back into the configuration.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_Config.decode_algorithmsappended this application's encode algorithm to the list object stored inapp.config["JWT_DECODE_ALGORITHMS"]instead of to a copy of it. Because that list is held byreference —
app.config.from_object()copies attributes by reference, so applications built from thesame object share one list — the append widened the configured algorithm allowlist for the application
and for every other application sharing it.
appBis configured for RS256 only, yet it now accepts HS256 tokens. Once appended, the entry ispermanent: the list now contains the algorithm, so the
not intest is false from then on and theallowlist can no longer be narrowed back by resetting
JWT_DECODE_ALGORITHMS.The fix copies the configured list before appending. The behaviour that
test_missing_algorithm_in_decode_algorithmspins is unchanged — the encode algorithm is stillincluded in what the property returns; it is simply no longer written back into the configuration.
Cases with
JWT_DECODE_ALGORITHMSunset or empty still resolve to[JWT_ALGORITHM]as before.