# CVE-2023-30861: Flask vulnerable to possible disclosure of permanent session cookie due to missing Vary: Cookie header

Source: https://junglewise.ai/threats/cve-2023-30861-flask-vulnerable-to-possible-disclosure-of-permanent-session  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2023-05-02  
License: CC BY 4.0 with a link back

CVE-2023-30861 · Severity: low · CVSS 3.1 · Published 2023-05-02

Flask is a lightweight WSGI web application framework. When all of the following conditions are met, a response containing data intended for one client may be cached and subsequently sent by the proxy to other clients. If the proxy also caches `Set-Cookie` headers, it may send one client's `session` cookie to other clients. The severity depends on the application's use of the session and the proxy'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 strip cookies or ignore responses with cookies.
2. The application sets `session.permanent = True`
3. The application does not access or modify the session at any point during a request.
4. `SESSION_REFRESH_EACH_REQUEST` enabled (the default).
5. The application does not set a `Cache-Control` header to indicate that a page is private or should not be cached.

This happens because vulnerable versions of Flask only set the `Vary: Cookie` header when the session is accessed or modified, not when it is refreshed (re-sent to update the expiration) without being accessed or modified. This issue has been fixed in versions 2.3.2 and 2.2.5.

Technologies: [flask (PyPI)](https://junglewise.ai/threats/technologies/flask). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2023-30861 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2023-30861 being exploited in the wild.

**How severe is CVE-2023-30861?** Low severity, with a CVSS score of 3.1, published 2 May 2023.

**Which products and versions are affected?** flask (PyPI) ECOSYSTEM:introduced=2.3.0,fixed=2.3.2, GIT:introduced=0,fixed=70f906c51ce49c485f1d355703e9cc3386b1cc2b,fixed=afd63b16170b7c047f5758eb910c416511e9c965|ECOSYSTEM:introduced=0,fixed=2.2.5,introduced=2.3.0,fixed=2.3.2.

**Is there a fix for CVE-2023-30861?** Yes. flask (PyPI): upgrade to 2.3.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**Am I affected by CVE-2023-30861?** Check whether you run flask (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- flask (PyPI): upgrade to 2.3.2 or later

  ```sh
  pip install "flask>=2.3.2"
  ```


## Affected products

- flask (PyPI) ECOSYSTEM:introduced=2.3.0,fixed=2.3.2, GIT:introduced=0,fixed=70f906c51ce49c485f1d355703e9cc3386b1cc2b,fixed=afd63b16170b7c047f5758eb910c416511e9c965|ECOSYSTEM:introduced=0,fixed=2.2.5,introduced=2.3.0,fixed=2.3.2

## Identifiers

- CVE-2023-30861
- GHSA-m2qf-hxjv-5gpq
- PYSEC-2023-62

## Related threats

- [PYSEC-2026-1377 - Flask uses fallback key instead of current signing key](https://junglewise.ai/threats/cve-2025-47278-flask-uses-fallback-key-instead-of-current-signing-key)
- [Flask session does not add `Vary: Cookie` header when accessed in some ways](https://junglewise.ai/threats/cve-2026-27205-flask-session-does-not-add-vary-cookie-header-when-accessed-in)
- [Pallets Project Flask is vulnerable to Denial of Service via Unexpected memory usage](https://junglewise.ai/threats/cve-2019-1010083-pallets-project-flask-is-vulnerable-to-denial-of-service-via)
- [Flask is vulnerable to Denial of Service via incorrect encoding of JSON data](https://junglewise.ai/threats/cve-2018-1000656-flask-is-vulnerable-to-denial-of-service-via-incorrect-encoding)
