Flask session does not add `Vary: Cookie` header when accessed in some ways
Published 19 Feb 2026 · Updated 10 Sept 2026
Is your project on an affected flask?
Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <3.1.3
- Fixed in
- 3.1.3
pip install 'flask>=3.1.3'Details
When the session object is accessed, Flask should set the Vary: Cookie header. This instructs caches not to cache the response, as it may contain information specific to a logged in user. This is handled in most cases, but some forms of access such as the Python in operator were overlooked.
The severity depends on the application's use of the session, and the cache's behavior regarding cookies. The risk depends on all these conditions being met.
1. The application must be hosted behind a caching proxy that does not ignore responses with cookies.
2. The application does not set a Cache-Control header to indicate that a page is private or should not be cached.
3. The application accesses the session in a way that does not access the values, only the keys, and does not mutate the session.
Is GHSA-68rp-wp8r-4726 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected flask, and gives you the command that fixes it.
More advisories for flask
- LowCVE-2025-47278Flask uses fallback key instead of current signing key · 13 May 2025
- HighCVE-2023-30861Flask vulnerable to possible disclosure of permanent session cookie due to missing Vary: Cookie header · 1 May 2023
- HighCVE-2019-1010083Pallets Project Flask is vulnerable to Denial of Service via Unexpected memory usage · 19 Jul 2019
- HighCVE-2018-1000656Flask is vulnerable to Denial of Service via incorrect encoding of JSON data · 23 Aug 2018
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.