CVE-2024-56326
JSON

5.4medium

Jinja has a sandbox breakout through indirect reference to format method

Severity
5.4medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.52% (higher than 45% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-q2x7-8rv6-6q7hPYSEC-2026-1475

Description

Jinja is an extensible templating engine. Prior to 3.1.5, 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. This vulnerability is fixed in 3.1.5.

Affected

Product or packageVersionsReported by
pallets jinja< 3.1.5CVE List
jinja2 (PyPI)before 3.1.5GitHub Advisory Database, PyPA Advisory Database
palletsprojects jinjabefore 3.1.5NVD

All scores

GitHub_M5.4medium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
CISA-ADP7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
GitHub7.8medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
GitHubmedium CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
PyPA Advisory Database7.8high CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

Classification

CWE-693CWE-1336

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

Jinja is an extensible templating engine. Prior to 3.1.5, 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. This vulnerability is fixed in 3.1.5.

GitHub Advisory Database

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.

NVD (es)

Jinja es un motor de plantillas extensible. Antes de la versión 3.1.5, una supervisión de cómo el entorno aislado de Jinja detecta llamadas a str.format permitía a un atacante que controlaba el contenido de una plantilla ejecutar código Python arbitrario. Para aprovechar la vulnerabilidad, un atacante necesita controlar el contenido de una plantilla. Que ese sea el caso depende del tipo de aplicación que utilice Jinja. Esta vulnerabilidad afecta a los usuarios de aplicaciones que ejecutan plantillas que no son de confianza. El sandbox de Jinja capta llamadas a str.format y garantiza que no escapen de la sandbox. Sin embargo, es posible almacenar una referencia al método de formato de una cadena maliciosa y luego pasarla a un filtro que lo llame. Estos filtros no están integrados en Jinja, pero podrían estar presentes a través de filtros personalizados en una aplicación. Después de la solución, estas llamadas indirectas también son gestionadas por la sandbox. Esta vulnerabilidad se solucionó en 3.1.5.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-56326 changed 2025-11-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-q2x7-8rv6-6q7h changed 2026-09-10CC-BY-4.0
NVDCVE-2024-56326 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2026-1475 changed 2026-07-07CC-BY-4.0