CVE-2024-56326
Jinja has a sandbox breakout through indirect reference to format method
Severity Score
Exploit Likelihood
Affected Versions
Public Exploits
0Exploited in Wild
-Decision
Descriptions
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.
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.
A flaw was found in the Jinja package. In affected versions of Jinja, 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 that execute untrusted templates. Jinja's sandbox does catch calls to str.format and ensures they don't escape the sandbox. However, storing a reference to a malicious string's format method is possible, then passing that to a filter that calls it. No such filters are built into Jinja but could be present through custom filters in an application. After the fix, such indirect calls are also handled by the sandbox.
It was discovered that Jinja2 incorrectly handled certain filenames when compiling template content. An attacker could possibly use this issue to execute arbitrary code. It was discovered that Jinja2 incorrectly handled string formatting calls. An attacker could possibly use this issue to execute arbitrary code.
CVSS Scores
SSVC
- Decision:Track*
Timeline
- 2024-12-19 CVE Reserved
- 2024-12-23 CVE Published
- 2024-12-24 EPSS Updated
- 2024-12-27 CVE Updated
- ---------- Exploited in Wild
- ---------- KEV Due Date
- ---------- First Exploit
CWE
- CWE-693: Protection Mechanism Failure
- CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine
CAPEC
References (5)
URL | Tag | Source |
---|---|---|
https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4 | X_refsource_misc | |
https://github.com/pallets/jinja/releases/tag/3.1.5 | X_refsource_misc | |
https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h | X_refsource_confirm |
URL | Date | SRC |
---|
URL | Date | SRC |
---|
URL | Date | SRC |
---|---|---|
https://access.redhat.com/security/cve/CVE-2024-56326 | 2025-02-04 | |
https://bugzilla.redhat.com/show_bug.cgi?id=2333856 | 2025-02-04 |