Vulnerability · Published Mar 5, 2025 · Assigned by GitHub_M

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

Medium 5.4

In plain English

A medium-severity security flaw in jinja from pallets. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.5% (higher than 43% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 4.0)5.4Medium
Exploit odds (30 days)0.5%top 56.5% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official 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 & fixed versions

EcosystemPackageFixed inAdvisory
AlmaLinux:10python3-jinja23.1.6-1.el10_0ALSA-2025:7476
AlmaLinux:8python3-jinja22.10.1-7.el8_10ALSA-2025:3388
AlmaLinux:9python3-jinja22.11.3-8.el9_5ALSA-2025:3406
AlmaLinux:10python3-jinja2+i18n3.1.6-1.el10_0ALSA-2025:7476
Alpine:v3.20py3-jinja23.1.6-r0ALPINE-CVE-2025-27516
Alpine:v3.21py3-jinja23.1.6-r0ALPINE-CVE-2025-27516
Alpine:v3.22py3-jinja23.1.6-r0ALPINE-CVE-2025-27516
Alpine:v3.23py3-jinja23.1.6-r0ALPINE-CVE-2025-27516
Alpine:v3.24py3-jinja23.1.6-r0ALPINE-CVE-2025-27516
Debian:12jinja23.1.2-1+deb12u3DEBIAN-CVE-2025-27516
Debian:13jinja23.1.6-1DEBIAN-CVE-2025-27516
Debian:14jinja23.1.6-1DEBIAN-CVE-2025-27516
PyPIjinja23.1.6PYSEC-2026-1471
PyPIjinja23.1.6GHSA-cpwx-vrp4-4pq7
Rocky Linux:9fence-agents0:4.10.0-76.el9_5.6RLSA-2025:3113
Rocky Linux:10python-jinja20:3.1.6-1.el10_0RLSA-2025:7476
Rocky Linux:8python-jinja20:2.10.1-7.el8_10RLSA-2025:3388
Rocky Linux:9python-jinja20:2.11.3-8.el9_5RLSA-2025:3406
Ubuntu:22.04:LTSjinja23.0.3-1ubuntu0.4USN-7343-1
Ubuntu:22.04:LTSjinja23.0.3-1ubuntu0.4UBUNTU-CVE-2025-27516
Ubuntu:24.04:LTSjinja23.1.2-1ubuntu1.3USN-7343-1
Ubuntu:24.04:LTSjinja23.1.2-1ubuntu1.3UBUNTU-CVE-2025-27516

Affected products (as reported)

VendorProductVersions
pallets jinja < 3.1.6

Weakness: CWE-1336 · Vector: 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

References