CVE-2025-27516 — jinja2
Fix: pallets/jinja@90457bbCVE-2025-27516 is a CWE-1336 vulnerability in jinja2. A fix is available for jinja2 — see the affected versions and patch details below.
Jinja sandbox breakout through attr filter selecting format method
Exploitation Status
No confirmed exploitation observed yet
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2025-27516.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Real-World Exposure
jinja2Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
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 Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | jinja2 | all versions | 3.1.6pip install --upgrade 'jinja2==3.1.6' |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for jinja2, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update jinja2 to 3.1.6 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2025-27516 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like CVE-2025-27516 can be triaged on real exposure rather than presence alone.
Tailored to CVE-2025-27516. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
This vulnerability is rated as important severity due to the potential for an attacker to bypass Jinja's sandbox by exploiting the |attr filter, by controlling template content, an attacker can execute arbitrary Python code, impacting the integrity, confidentiality, and availability of the system. While the attack…
| Product | Fixed in | Advisory |
|---|---|---|
| Ansible Automation Platform Execution Environments | ansible-automation-platform/ee-minimal-rhel8:2.16.14-11 | RHSA-2025:2664 |
| Red Hat Ansible Automation Platform 2.4 for RHEL 8 | automation-controller-0:4.5.20-1.el8ap | RHSA-2025:3123 |
| Red Hat Ansible Automation Platform 2.4 for RHEL 8 | ansible-automation-platform-24/lightspeed-rhel8:2.4.250225-5 | RHSA-2025:3124 |
| Red Hat Ansible Automation Platform 2.5 for RHEL 8 | automation-controller-0:4.6.10-1.el8ap | RHSA-2025:3160 |
| Red Hat Ansible Automation Platform 2.5 for RHEL 8 | ansible-automation-platform-25/lightspeed-rhel8:2.5.250318-2 | RHSA-2025:3162 |
| Red Hat Enterprise Linux 10 | python-jinja2-0:3.1.6-1.el10_0 | RHSA-2025:7476 |
| Red Hat Enterprise Linux 8 | python-jinja2-0:2.10.1-7.el8_10 | RHSA-2025:3388 |
| Red Hat Enterprise Linux 8.2 Advanced Update Support | python-jinja2-0:2.10.1-2.el8_2.4 | RHSA-2025:3671 |
Frequently Asked Questions
Is CVE-2025-27516 in your dependencies?
O3 Security finds CVE-2025-27516 across PyPI dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.