Vulnerabilities in pkg:pypi/Flask-Caching

PACKAGE
Advisory Identifier: GHSA-656c-6cxf-hvcv
Advisory Summary

CVE-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.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/Flask-Caching

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/Flask-Caching. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-656c-6cxf-hvcv CVE-2021-33026 MODERATE Deserialization of Untrusted Data in Flask-Caching

CVE-2021-33026 at a Glance

CVE Identifier CVE-2021-33026
GHSA Identifier GHSA-656c-6cxf-hvcv
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Flask Caching
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (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.

Flask-Caching fixed: Latest secure release
pip install Flask-Caching>=Latest secure release
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-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

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. However, this is not a high-severity issue, as for an attack like this to work, an attacker must: 1. Be able to write arbitrary values to the cache 2. Be able to generate a cache key that will collide with a value being read by the application 3. Cause the application to read a maliciously-injected value Any 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).

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?
CVE-2021-33026 is a security vulnerability in Flask Caching involving Deserialization of Untrusted Data in Flask-Caching under CWE-502: Deserialization of Untrusted Data.
Which Flask Caching versions are affected?
Affected versions include releases prior to current release patches across affected packages: Flask-Caching.
What version fixes CVE-2021-33026?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is Flask-Caching affected?
Yes, Flask-Caching is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2021-33026?
CVE-2021-33026 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2021-33026?
CVE-2021-33026 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check PyPI dependencies for CVE-2021-33026?
Run the dependency tree command: 'pip show Flask-Caching'. 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-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"
  }
}