First published: Wed Mar 05 2025(Updated: )
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.
Credit: security-advisories@github.com
Affected Software | Affected Version | How to fix |
---|---|---|
pip/Jinja2 | <=3.1.5 | 3.1.6 |
IBM Storage Defender Resiliency Service | <=2.0.0 - 2.0.12 | |
debian/jinja2 | <=2.11.3-1<=3.1.2-1+deb12u2 | 2.11.3-1+deb11u3 3.1.6-1 |
Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.
CVE-2025-27516 is rated as a critical vulnerability due to its potential to enable arbitrary code execution.
To mitigate CVE-2025-27516, upgrade Jinja2 to version 3.1.6 or later.
CVE-2025-27516 affects users of Jinja2 versions 3.1.5 and earlier.
CVE-2025-27516 allows an attacker to execute arbitrary Python code through controlled template content.
You can identify if you're vulnerable to CVE-2025-27516 by checking if you are using Jinja2 version 3.1.5 or earlier.