GitHub Advisoryadvisory · PyPI

GHSA-q2x7-8rv6-6q7h Jinja has a sandbox breakout through indirect reference to format method

MEDIUM Published 2024-12-23 Modified 2025-11-03 Official page ↗
Aliases
CVE-2024-56326
Ecosystem
PyPI
Packages
jinja2
Severity
Moderate
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Weaknesses
CWE-693
Reviewed
2024-12-23

Affected packages

• PyPI jinja2: < 3.1.5 → fixed in 3.1.5

Description

An oversight in how the Jinja sandboxed environment detects calls to `str.format` 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 store a reference to a malicious string's `format` method, then pass that to a filter that calls it. No such filters are built-in to Jinja, but could be present through custom filters in an application. After the fix, such indirect calls are also handled by the sandbox.

Related

Alias · CVE (1)

  • CVE-2024-56326 Jinja is an extensible templating engine. vulnerability

Weakness · CWE (1)

  • CWE-693 Protection Mechanism Failure weakness

References