Flask Permanent Session Cookie Disclosure via Missing Vary Header
CVE-2023-30861 is an information-disclosure flaw in Flask's handling of refreshed permanent sessions. When Flask refreshes a permanent session cookie without the application accessing or modifying the session, vulnerable versions resend the cookie but do not add the HTTP Vary: Cookie response header. A shared caching proxy can therefore treat responses for clients with different cookies as equivalent and cache a response intended for one client for delivery to another. The issue is fixed in Flask 2.2.5 and 2.3.2.
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
What an attacker gets, and what they’ve been doing with it.
A shared proxy may disclose response content intended for one client to other clients. If that proxy also caches and replays Set-Cookie headers, it can expose one client's Flask session cookie to another client. The resulting impact depends on the application's session design and the proxy's cookie-caching behavior, but may include session hijacking and unauthorized access under the affected user's session.
If you can’t patch tonight, do this now.
Until updates can be deployed, configure shared caching proxies not to cache responses containing cookies and not to cache or replay Set-Cookie headers. Mark relevant responses with restrictive Cache-Control directives, such as private or no-store, as appropriate. Where operationally acceptable, avoid permanent sessions or disable SESSION_REFRESH_EACH_REQUEST.
Patch, then assume compromise.
Upgrade Flask to version 2.2.5, 2.3.2, or a later supported release containing the fix. For vendor-distributed Flask packages, apply the vendor's security update. Validate that session-bearing responses have appropriate cache-control behavior and that upstream proxies honor cookie-based response variation.
1 exploit validated by Mallory's analysis. Hidden: 1 rejected by Mallory's analysis as not a working exploit.
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
2 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.