CVE-2019-10906: Jinja2 Sandbox Escape
Summary
CVE-2019-10906: In Pallets Jinja before 2.10.1, str.format_map allows a sandbox escape. Affects jinja2 versions < 2.10.1. Fixed in 2.10.1. How to fix ↓
Also tracked for
- jinja2 · Debian:11
The same CVE-2019-10906 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Jinja2 is a popular templating engine for Python. It provides a way to generate dynamic HTML, XML, or other markup formats. Jinja2 allows developers to create templates with placeholders that can be filled with data at runtime. This vulnerability, identified as CVE-2019-10906, affects Jinja2 versions prior to 2.10.1. It specifically impacts the str.format_map function, which can be exploited to escape the sandbox environment.
Vulnerability Detail
The vulnerability in Jinja2's str.format_map function allows an attacker to break out of the sandbox and execute arbitrary code. The sandbox is a security feature that restricts the capabilities of the template engine to prevent code execution and access to sensitive resources. By exploiting this vulnerability, an attacker can bypass these restrictions and potentially perform unauthorized actions, such as accessing sensitive data or executing malicious code on the server.
How To Fix
Latest published version: 3.1.6 as of 23 Oct 2026
pip install --upgrade "jinja2==3.1.6"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
2.10.1
This is the first release that contains the fix.
pip install --upgrade "jinja2==2.10.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version of Jinja2 is not immediately feasible, a possible workaround is to avoid using the str.format_map function in templates. Instead, developers can use alternative methods or constructs provided by Jinja2 that do not exhibit the same vulnerability. It is important to carefully review and test any changes made to ensure they do not introduce new security risks.
Conclusion
The CVE-2019-10906 vulnerability in Jinja2's str.format_map function allows for a sandbox escape, enabling an attacker to execute arbitrary code. To mitigate this vulnerability, it is essential to upgrade Jinja2 to version 2.10.1 or later. Alternatively, developers can avoid using the str.format_map function until the upgrade is feasible. For further assistance or support in addressing this vulnerability, please contact DevNack.com.
See every vulnerability recorded for jinja2 →
FAQ
Jinja2 is a templating engine for Python that allows developers to generate dynamic HTML, XML, or other markup formats. It provides a flexible and efficient way to create templates with placeholders that can be filled with data at runtime.
The vulnerability in Jinja2's str.format_map function allows an attacker to escape the sandbox and execute arbitrary code. This can lead to unauthorized access to sensitive data, server compromise, or the execution of malicious actions on the affected system.
To fix this vulnerability, it is recommended to upgrade Jinja2 to version 2.10.1 or later. This version includes a fix for the str.format_map vulnerability. Developers should update their Jinja2 dependency using the appropriate package manager or command.
If upgrading to the latest version of Jinja2 is not immediately feasible, developers can avoid using the str.format_map function in templates. Alternative methods or constructs provided by Jinja2 can be used to achieve the desired functionality without exposing the vulnerability.
At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is crucial to apply the recommended fix or workaround as soon as possible to mitigate the risk of potential attacks.
Related vulnerabilities
Recent vulnerabilities recorded for jinja2.