CVE-2021-33026: Flask Caching Deserialization Of Untrusted Data Vulnerability
MODERATECVE-2021-33026 is a MODERATE (CVSS 4.2) deserialization of untrusted data vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Flask Caching libraries in the PyPI ecosystem. The issue involves deserialization of untrusted data in flask-caching. Remediation is available in the latest vendor maintenance releases.
CVE-2021-33026 at a Glance
Security Impact
CVSS: 4.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:H/A:N).
How to Fix CVE-2021-33026
To remediate this vulnerability, upgrade all affected Flask Caching 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-Caching>=Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show Flask-Caching
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2021-33026, inspect your installed packages using pip:
pip show Flask-Caching
Analyze the terminal output to locate any version of Flask Caching in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The pip show Flask-Caching command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Flask Caching, 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-2021-33026 Affected Flask Caching Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
Flask-Caching
|
PyPI |
≤ 1.10.1
|
|
References
Frequently Asked Questions
What is CVE-2021-33026?
Which Flask Caching versions are affected?
What version fixes CVE-2021-33026?
Is Flask-Caching affected?
What is the CVSS score of CVE-2021-33026?
What CWE is associated with CVE-2021-33026?
How can I check PyPI dependencies for CVE-2021-33026?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-656c-6cxf-hvcv",
"modified" : "2022-09-20T13:31:06Z",
"published" : "2021-06-18T18:33:40Z",
"aliases" : [ "CVE-2021-33026" ],
"summary" : "Deserialization of Untrusted Data in Flask-Caching",
"details" : "Flask-Cache adds easy cache support to Flask. The Flask-Caching extension through 1.10.1 for Flask relies on Pickle for serialization, which may lead to remote code execution or local privilege escalation. If an attacker gains access to cache storage (e.g., filesystem, Memcached, Redis, etc.), they can construct a crafted payload, poison the cache, and execute Python code.\n\nHowever, this is not a high-severity issue, as for an attack like this to work, an attacker must:\n\n1. Be able to write arbitrary values to the cache\n2. Be able to generate a cache key that will collide with a value being read by the application\n3. Cause the application to read a maliciously-injected value\n\nAny situation where all 3 of those is true is a situation where the application has larger problems; for example, if someone's able to inject malicious cached rendered pages into a Flask app's cache, then they can make the website say literally anything they want, regardless of whether it involves the execution of remote code. Basically, the Pickle vulnerability follows from a website already being extremely vulnerable (due to conditions 1 and 2 being met).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "Flask-Caching"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "1.10.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-33026"
}, {
"type" : "WEB",
"url" : "https://github.com/pallets-eco/flask-caching/pull/209#issuecomment-1136397937"
}, {
"type" : "WEB",
"url" : "https://github.com/sh4nks/flask-caching/pull/209"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-656c-6cxf-hvcv"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/flask-caching/PYSEC-2021-13.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sh4nks/flask-caching"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-269", "CWE-502" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-17T17:25:38Z",
"nvd_published_at" : "2021-05-13T23:15:00Z"
}
}