CVE-2021-33026: Flask-Caching Remote Code Execution Vulnerability

flask-caching Updated 02 Oct 2025

Summary

13/05/2021
N/A
No i
Unrated
Not published

PYSEC-2021-13: 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. Affects flask-caching versions >= 1.0.0. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Flask-Caching is an extension for Flask, a popular Python web framework. It provides caching functionality to improve the performance of Flask applications. The extension relies on Pickle for serialization, which is a vulnerability in this case. Pickle is a Python module used for object serialization and deserialization. However, it can be abused to execute arbitrary code if the attacker gains access to the cache storage. This vulnerability affects Flask-Caching versions up to 1.10.1.

Vulnerability Detail

The vulnerability in Flask-Caching arises from the use of Pickle for serialization. If an attacker gains access to the cache storage, they can construct a crafted payload and poison the cache. This allows them to execute arbitrary Python code, leading to remote code execution or local privilege escalation. The impact of this vulnerability can be severe, as it allows an attacker to execute arbitrary code within the context of the Flask application.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If upgrading Flask-Caching is not immediately feasible, a possible workaround is to disable caching or use an alternative caching mechanism that does not rely on Pickle for serialization. This can be achieved by configuring Flask to use a different caching backend, such as Redis or Memcached, which have built-in support for safe serialization. Here's an example of how to configure Flask to use Redis as the caching backend:

from flask import Flask
from flask_caching import Cache

app = Flask(__name__)

app.config['CACHE_TYPE'] = 'redis'
app.config['CACHE_REDIS_URL'] = 'redis://localhost:6379'

cache = Cache(app)

# Rest of the Flask application code

By using Redis as the caching backend, the vulnerability is mitigated as Redis uses a safe serialization method.

Conclusion

The Flask-Caching extension through version 1.10.1 is vulnerable to remote code execution or local privilege escalation due to its reliance on Pickle for serialization. Upgrading to version 1.10.2 or later is recommended to fix the vulnerability. Alternatively, disabling caching or using a different caching mechanism can serve as a temporary workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for flask-caching →

Share this vulnerability

FAQ

Flask-Caching is an extension for Flask that provides caching functionality to improve the performance of Flask applications.

Pickle is a Python module used for object serialization and deserialization. It is the serialization method used by Flask-Caching, which is vulnerable in this case.

Remote code execution refers to the ability of an attacker to execute arbitrary code on a remote system. In the case of this vulnerability, an attacker can execute Python code within the context of the Flask application.

To fix this vulnerability, it is recommended to upgrade Flask-Caching to version 1.10.2 or later.

A possible workaround is to disable caching or use an alternative caching mechanism that does not rely on Pickle for serialization. Configuring Flask to use a different caching backend, such as Redis or Memcached, can mitigate the vulnerability.

Related vulnerabilities

Recent vulnerabilities recorded for flask-caching.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback