Skip to content

Commit 77411ad

Browse files
jayaddisonpgjones
authored andcommitted
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 84064df commit 77411ad

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
0.11.1 (Unreleased)
2+
-------------------
3+
4+
* Flask backport: Fix signing key selection order when key rotation is enabled
5+
via ``SECRET_KEY_FALLBACKS``.
6+
<https://github.com/pallets/flask/security/advisories/GHSA-4grg-w6v8-c28g>
7+
18
0.11.0 2024-12-26
29
-----------------
310

src/quart_auth/extension.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@ def load_token(self, token: str, app: Optional[Quart] = None) -> Optional[str]:
205205
if app is None:
206206
app = current_app
207207

208-
keys = [app.secret_key]
208+
keys = []
209209

210210
if fallbacks := app.config.get("SECRET_KEY_FALLBACKS"):
211211
keys.extend(fallbacks)
212212

213+
keys.append(app.secret_key) # itsdangerous expects current key at top
214+
213215
serializer = self.serializer_class(keys, self.salt) # type: ignore[arg-type]
214216
try:
215217
return serializer.loads(token, max_age=self.duration)

0 commit comments

Comments
 (0)