CVE-2024-56326: Jinja has a sandbox breakout through indirect reference to format method
An oversight in how the Jinja sandboxed environment detects calls to `str.format` allows an attacker that controls the content of a template to execute arbitrary Python code. To exploit the vulnerability, an attacker needs to control the content of a template. Whether that is the case depends on the type of application using Jinja. This vulnerability impacts users of applications which execute untrusted templates. Jinja's sandbox does catch calls to `str.format` and ensures they don't escape the sandbox. However, it's possible to store a reference to a malicious string's `format` method, then pass that to a filter that calls it. No such filters are built-in to Jinja, but could be present through custom filters in an application. After the fix, such indirect calls are also handled by the sandbox.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2024-56326?
CVE-2024-56326 is classified as a high severity vulnerability due to its potential for arbitrary code execution.
How do I fix CVE-2024-56326?
To fix CVE-2024-56326, upgrade to Jinja2 version 3.1.5 or later.
Who is affected by CVE-2024-56326?
CVE-2024-56326 affects Jinja2 versions up to and including 3.1.4.
What type of attack does CVE-2024-56326 enable?
CVE-2024-56326 enables attackers to execute arbitrary Python code through a compromised template.
Is there a workaround for CVE-2024-56326?
There are no officially recommended workarounds for CVE-2024-56326; the best action is to update to the latest version.