5.4medium
Jinja sandbox breakout through attr filter selecting format method
- Severity
- 5.4medium CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.51% (higher than 44% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-cpwx-vrp4-4pq7PYSEC-2026-1471
Description
Jinja is an extensible templating engine. Prior to 3.1.6, an oversight in how the Jinja sandboxed environment interacts with the |attr filter 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 use the |attr filter to get a reference to a string's plain format method, bypassing the sandbox. After the fix, the |attr filter no longer bypasses the environment's attribute lookup. This vulnerability is fixed in 3.1.6.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| pallets jinja | < 3.1.6 | CVE List |
| jinja2 (PyPI) | before 3.1.6 | GitHub Advisory Database, PyPA Advisory Database |
| palletsprojects jinja | before 3.1.6 | NVD |
| debian debian_linux | 11.0 | NVD |
All scores
| GitHub_M | 5.4medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| NVD | 8.8high CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H |
| PyPA Advisory Database | Not scored CVSS:4.0 | CVSS: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
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.6, an oversight in how the Jinja sandboxed environment interacts with the |attr filter 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 use the |attr filter to get a reference to a string's plain format method, bypassing the sandbox. After the fix, the |attr filter no longer bypasses the environment's attribute lookup. This vulnerability is fixed in 3.1.6.
GitHub Advisory Database
An oversight in how the Jinja sandboxed environment interacts with the |attr filter 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 use the |attr filter to get a reference to a string's plain format method, bypassing the sandbox. After the fix, the |attr filter no longer bypasses the environment's attribute lookup.
NVD (es)
Jinja es un motor de plantillas extensible. Antes de la versión 3.1.6, un descuido en la forma en que el entorno aislado de Jinja interactúa con el filtro |attr permite que un atacante que controla el contenido de una plantilla ejecute código Python arbitrario. Para explotar la vulnerabilidad, un atacante debe controlar el contenido de una plantilla. Si ese es el caso depende del tipo de aplicación que utilice Jinja. Esta vulnerabilidad afecta a los usuarios de aplicaciones que ejecutan plantillas no confiables. El entorno aislado de Jinja detecta las llamadas a str.format y garantiza que no escapen del entorno aislado. Sin embargo, es posible utilizar el filtro |attr para obtener una referencia al método de formato simple de una cadena, sin pasar por el entorno aislado. Después de la corrección, el filtro |attr ya no pasa por alto la búsqueda de atributos del entorno. Esta vulnerabilidad se corrigió en la versión 3.1.6.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-27516 changed 2026-02-26 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-cpwx-vrp4-4pq7 changed 2026-11-18 | CC-BY-4.0 |
| NVD | CVE-2025-27516 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-1471 changed 2026-07-07 | CC-BY-4.0 |