CWE
1336
EPSS
0.065%
Advisory Published
Advisory Published
Updated

CVE-2025-27516: Jinja sandbox breakout through attr filter selecting format method

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 SoftwareAffected VersionHow 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

Never miss a vulnerability like this again

Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.

Reference Links

Parent vulnerabilities

(Appears in the following advisories)

Frequently Asked Questions

  • What is the severity of CVE-2025-27516?

    CVE-2025-27516 is rated as a critical vulnerability due to its potential to enable arbitrary code execution.

  • How do I fix CVE-2025-27516?

    To mitigate CVE-2025-27516, upgrade Jinja2 to version 3.1.6 or later.

  • Who is affected by CVE-2025-27516?

    CVE-2025-27516 affects users of Jinja2 versions 3.1.5 and earlier.

  • What does CVE-2025-27516 allow an attacker to do?

    CVE-2025-27516 allows an attacker to execute arbitrary Python code through controlled template content.

  • How can I identify if I'm vulnerable to CVE-2025-27516?

    You can identify if you're vulnerable to CVE-2025-27516 by checking if you are using Jinja2 version 3.1.5 or earlier.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2025 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203