CVE-2023-30861: Flask Cookie Header Vulnerability

HIGH
Advisory Identifier: GHSA-m2qf-hxjv-5gpq
CVSS 7.5
CWE-539
Published
Advisory Summary

CVE-2023-30861 is a HIGH (CVSS 7.5) cookie header vulnerability (CWE-539: Use of Persistent Cookies Containing Sensitive Information) affecting Flask libraries in the PyPI ecosystem. The issue involves cookie header. Remediation is available by upgrading affected packages to version 2.3.2, 2.2.5.

CVE-2023-30861 at a Glance

CVE Identifier CVE-2023-30861
GHSA Identifier GHSA-m2qf-hxjv-5gpq
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-539: Use of Persistent Cookies Containing Sensitive Information
Affected Product Flask
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2023-30861

To remediate this vulnerability, upgrade all affected Flask dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Flask fixed: 2.3.2
pip install Flask>=2.3.2
Flask fixed: 2.2.5
pip install Flask>=2.2.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Flask

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2023-30861, inspect your installed packages using pip:

pip show Flask

Analyze the terminal output to locate any version of Flask in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.3.2), your application is affected.

Note: The pip show Flask command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-539: Use of Persistent Cookies Containing Sensitive Information, where the web application uses persistent cookies, but the cookies contain sensitive information. In Flask, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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`](https://flask.palletsprojects.com/en/2.3.x/api/#flask.session.permanent). 2. The application does not access or modify the session at any point during a request. 4. [`SESSION_REFRESH_EACH_REQUEST`](https://flask.palletsprojects.com/en/2.3.x/config/#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.

CVE-2023-30861 Affected Flask Versions

2 component(s)
Fixed Versions:
2.3.22.2.5
Product / Package Ecosystem Affected Versions Fixed Version
Flask
PyPI
≥ 2.3.0
< 2.3.2
2.3.2
Flask
PyPI
< 2.2.5
2.2.5

References

Frequently Asked Questions

What is CVE-2023-30861?
CVE-2023-30861 is a security vulnerability in Flask involving Cookie header under CWE-539: Use of Persistent Cookies Containing Sensitive Information.
Which Flask versions are affected?
Affected versions include releases prior to 2.3.2, 2.2.5 across affected packages: Flask.
What version fixes CVE-2023-30861?
Upgrading to 2.3.2, 2.2.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Flask affected?
Yes, Flask is affected in releases prior to 2.3.2, 2.2.5. Upgrade your dependency to 2.3.2, 2.2.5 or later.
What is the CVSS score of CVE-2023-30861?
CVE-2023-30861 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2023-30861?
CVE-2023-30861 is classified under CWE-539: Use of Persistent Cookies Containing Sensitive Information (The web application uses persistent cookies, but the cookies contain sensitive information.).
How can I check PyPI dependencies for CVE-2023-30861?
Run the dependency tree command: 'pip show Flask'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m2qf-hxjv-5gpq",
  "modified" : "2024-09-20T17:51:00Z",
  "published" : "2023-05-01T19:22:20Z",
  "aliases" : [ "CVE-2023-30861" ],
  "summary" : "Flask vulnerable to possible disclosure of permanent session cookie due to missing Vary: Cookie header",
  "details" : "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.\n\n1. The application must be hosted behind a caching proxy that does not strip cookies or ignore responses with cookies.\n2. The application sets [`session.permanent = True`](https://flask.palletsprojects.com/en/2.3.x/api/#flask.session.permanent).\n2. The application does not access or modify the session at any point during a request.\n4. [`SESSION_REFRESH_EACH_REQUEST`](https://flask.palletsprojects.com/en/2.3.x/config/#SESSION_REFRESH_EACH_REQUEST) is enabled (the default).\n5. The application does not set a `Cache-Control` header to indicate that a page is private or should not be cached.\n\nThis 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Flask"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.3.0"
      }, {
        "fixed" : "2.3.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Flask"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.2.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pallets/flask/security/advisories/GHSA-m2qf-hxjv-5gpq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-30861"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/flask/commit/70f906c51ce49c485f1d355703e9cc3386b1cc2b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/flask/commit/afd63b16170b7c047f5758eb910c416511e9c965"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pallets/flask"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/flask/releases/tag/2.2.5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/flask/releases/tag/2.3.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/flask/PYSEC-2023-62.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/08/msg00024.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20230818-0006"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2023/dsa-5442"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-539" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-01T19:22:20Z",
    "nvd_published_at" : "2023-05-02T18:15:52Z"
  }
}