Medium

Deserialization of Untrusted Data in Flask-Caching

  • Disclosed: 18.06.2021
  • Updated: 11.10.2026 11:19

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

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) flask-caching <= 1.10.1 no fix

References

CVSS score 4.2/10
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:H/A:N
Weakness (CWE)
CWE-269, CWE-502
Platform
Python (PyPI)
Package
flask-caching
Disclosed
18.06.2021
Updated
11.10.2026 11:19

Sources and licenses

OSV / GitHub Advisory Database - GHSA-656c-6cxf-hvcv - CC BY 4.0

Vulnerability history: flask-caching

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

This is the only known vulnerability of this package.

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.