Critical Vulnerability in Jinja2: Arbitrary Code Execution via |attr Filter

py3-jinja2 Updated 02 Oct 2025

Summary

05/03/2025
N/A
Yes i
Unrated
Not published

CVE-2025-27516: Jinja is an extensible templating engine. Affects py3-jinja2 across 2 version ranges.

< 3.1.6-r0 < 90457bbf33b8662926ae65cdde4c4c32e756e403

Fixed in 3.1.6-r0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Jinja2 is an extensible templating engine for Python, widely used for rendering templates in web applications. It allows developers to create dynamic web pages by embedding Python-like expressions within HTML. Jinja2's sandboxing feature is designed to execute untrusted templates safely, but it has a vulnerability that can be exploited if an attacker controls the template content.

Vulnerability Detail

The vulnerability, identified as CVE-2025-27516, arises from an oversight in the Jinja sandboxed environment's interaction with the |attr filter. This flaw allows an attacker who controls template content to execute arbitrary Python code, potentially compromising the application. The vulnerability affects applications that execute untrusted templates, as the |attr filter can bypass the sandbox's restrictions, leading to unauthorized access and execution of code.

How To Fix

Minimum fixed version

3.1.6-r0

This is the first release that contains the fix.

sudo apk add --upgrade py3-jinja2

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the |attr filter in templates that may be controlled by untrusted users. Instead, consider using safer alternatives or sanitizing input to prevent exploitation.

Conclusion

CVE-2025-27516 is a critical vulnerability in Jinja2 that allows for arbitrary code execution through the |attr filter. It is essential for developers to update to version 3.1.6 or later to protect their applications. Utilizing tools like Vulert can help monitor and identify vulnerabilities in real-time.

See every vulnerability recorded for py3-jinja2 →

Share this vulnerability

FAQ

CVE-2025-27516 is a vulnerability in Jinja2 that allows arbitrary code execution through the |attr filter if an attacker controls the template content.

You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in your software. Visit Vulert Scanner to analyze your manifest file.

The risks include unauthorized execution of arbitrary Python code, which can lead to data breaches, system compromise, and loss of integrity in your application.

Yes, the vulnerability is fixed in Jinja2 version 3.1.6 and later. It is recommended to update your package to this version.

If immediate updates are not possible, avoid using the |attr filter in your templates and consider implementing input validation to mitigate the risk.

Related vulnerabilities

Recent vulnerabilities recorded for py3-jinja2.

How To Fix

Minimum fixed version

3.1.6-r0

This is the first release that contains the fix.

sudo apk add --upgrade py3-jinja2

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback