Template Injection Affecting jinja2 package, versions [,3.1.6)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.04% (10th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-JINJA2-9292516
  • published6 Mar 2025
  • disclosed5 Mar 2025
  • creditsecuringapps

Introduced: 5 Mar 2025

CVE-2025-27516  (opens in a new tab)
CWE-1336  (opens in a new tab)

How to fix?

Upgrade Jinja2 to version 3.1.6 or higher.

Overview

Jinja2 is a template engine written in pure Python. It provides a Django inspired non-XML syntax but supports inline expressions and an optional sandboxed environment.

Affected versions of this package are vulnerable to Template Injection through the |attr filter. An attacker that controls the content of a template can escape the sandbox and execute arbitrary Python code by using the |attr filter to get a reference to a string's plain format method, bypassing the environment's attribute lookup.

Note:

This is only exploitable if the application executes untrusted templates.

References

CVSS Base Scores

version 4.0
version 3.1