Skip to main content

CVE-2025-27516 — Vulnerability in jinja2 — CVE Details

MEDIUM

Jinja2 vulnerable to sandbox breakout through attr filter selecting format method

Published March 5, 2025Updated November 18, 2026Source: OSV

What Should I Do?

Address in Next Maintenance Window

Low exploitation probability (0.59%). Schedule for your next planned update.

Does your project use an affected jinja2 version?

Paste your requirements.txt to check it for CVE-2025-27516 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my requirements.txt

Summary

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.

Advisory Timeline

  • First published March 5, 2025 (631 days ago).
  • Last revised November 18, 2026 — 622 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

pip
Update jinja2 to 3.1.6 or later
pip install "jinja2>=3.1.6"

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: PyPI (1).

PackageFixed In
jinja2 PyPI · Affected: 2.0, 2.0rc1, 2.1, 2.1.1 (+47 more)3.1.6

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.1 score means for each attack dimension.

Attack Vector
Local
Attack Complexity
Low
Privileges Required
Low
User Interaction
P
Scope
—
Confidentiality
—
Integrity
—
Availability
—

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

Frequently Asked Questions

What is CVE-2025-27516?
Jinja2 vulnerable to sandbox breakout through attr filter selecting format method. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 7.1/10).
How do I check if my project is affected by CVE-2025-27516?
CVE-2025-27516 affects jinja2. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2025-27516 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
7.1

Significant impact if exploited, or exploitable with modest effort.

EPSS Score (30-day exploit probability)
0.59%
EPSS percentile: 42.4

This is a below-median EPSS score — only 42.4% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.

Also Known As

GHSA-cpwx-vrp4-4pq7
PYSEC-2026-1471

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my requirements.txt