Skip to content

Commit 64febe0

Browse files
committed
secret key rotation: fix key list ordering
The `itsdangerous` serializer interface[1] expects keys to be provided with the oldest key at index zero and the active signing key at the end of the list. [1] - https://itsdangerous.palletsprojects.com/en/stable/serializer/#itsdangerous.serializer.Serializer (cherry picked from commit pallets/flask@fb54159) Conflicts: CHANGES.rst src/flask/sessions.py tests/test_basic.py
1 parent 8fb9bb5 commit 64febe0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Version 0.20.1
2+
3+
Unreleased
4+
5+
- Flask backport: Fix signing key selection order when key rotation is enabled
6+
via ``SECRET_KEY_FALLBACKS``.
7+
<https://github.com/pallets/flask/security/advisories/GHSA-4grg-w6v8-c28g>
8+
19
## Version 0.20.0
210

311
Released 2024-12-23

src/quart/sessions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ def get_signing_serializer(self, app: Quart) -> URLSafeTimedSerializer | None:
149149
if not app.secret_key:
150150
return None
151151

152-
keys: list[str | bytes] = [app.secret_key]
152+
keys: list[str | bytes] = []
153153

154154
if fallbacks := app.config["SECRET_KEY_FALLBACKS"]:
155155
keys.extend(fallbacks)
156156

157+
keys.append(app.secret_key) # itsdangerous expects current key at top
157158
options = {
158159
"key_derivation": self.key_derivation,
159160
"digest_method": self.digest_method,

0 commit comments

Comments
 (0)