CVE-2023-30861
JSON

7.5high

Flask vulnerable to possible disclosure of permanent session cookie due to missing Vary: Cookie header

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
1.25% (higher than 70% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-m2qf-hxjv-5gpqPYSEC-2023-62

Description

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.

Affected

Product or packageVersionsReported by
pallets flask>= 2.3.0, < 2.3.2, < 2.2.5CVE List
flask (PyPI)from 2.3.0 before 2.3.2, before 2.2.5, before 70f906c51ce49c485f1d355703e9cc3386b1cc2b, before afd63b16170b7c047f5758eb910c416511e9c965GitHub Advisory Database, PyPA Advisory Database
palletsprojects flaskbefore 2.2.5, from 2.3.0 before 2.3.2NVD

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Classification

CWE-539

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

When all of the following conditions are met, a response containing data intended for one client may be cached and subsequently sent by a 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 is 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.

References

https://github.com/pallets/flask/security/advisories/GHSA-m2qf-hxjv-5gpqadvisory, vendor-advisory, web
https://github.com/pallets/flask/commit/70f906c51ce49c485f1d355703e9cc3386b1cc2bfix, patch, web
https://github.com/pallets/flask/commit/afd63b16170b7c047f5758eb910c416511e9c965fix, patch, web
https://github.com/pallets/flask/releases/tag/2.2.5release-notes, web
https://github.com/pallets/flask/releases/tag/2.3.2release-notes, web
https://www.debian.org/security/2023/dsa-5442web
https://security.netapp.com/advisory/ntap-20230818-0006/
https://lists.debian.org/debian-lts-announce/2023/08/msg00024.htmlweb
https://nvd.nist.gov/vuln/detail/CVE-2023-30861advisory
https://github.com/pallets/flaskpackage
https://github.com/pypa/advisory-database/tree/main/vulns/flask/PYSEC-2023-62.yamlweb
https://security.netapp.com/advisory/ntap-20230818-0006web

Sources

SourceRecordLicence
CVE ListCVE-2023-30861 changed 2025-02-13CVE Terms of Use
GitHub Advisory DatabaseGHSA-m2qf-hxjv-5gpq changed 2026-09-10CC-BY-4.0
NVDCVE-2023-30861 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2023-62 changed 2023-11-08CC-BY-4.0