CVE-2023-30861: Flask Cookie Header Vulnerability
HIGHCVE-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
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).
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.
pip install Flask>=2.3.2
pip install Flask>=2.2.5
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
CVE-2023-30861 Affected Flask Versions
2 component(s)| 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?
Which Flask versions are affected?
What version fixes CVE-2023-30861?
Is Flask affected?
What is the CVSS score of CVE-2023-30861?
What CWE is associated with CVE-2023-30861?
How can I check PyPI dependencies for CVE-2023-30861?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}