---
id: CVE-2024-56326
aliases:
  - GHSA-q2x7-8rv6-6q7h
  - PYSEC-2026-1475
title: Jinja has a sandbox breakout through indirect reference to format method
summary: Jinja has a sandbox breakout through indirect reference to format method
severity: high
cvss: 7.8
cvssVector: 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'
vendor: jinja2
product: jinja2
ecosystem: pip
affected:
  - jinja2 < 3.1.5
patched:
  - jinja2 3.1.5
published: '2024-12-23'
updated: '2026-09-10'
sourceUpdated: '2026-09-10T03:50:21.662855250Z'
source: OSV
sourceUrl: 'https://osv.dev/vulnerability/GHSA-q2x7-8rv6-6q7h'
references:
  - url: 'https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h'
  - url: 'https://nvd.nist.gov/vuln/detail/CVE-2024-56326'
  - url: >-
      https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4
  - url: 'https://github.com/pallets/jinja'
  - url: 'https://github.com/pallets/jinja/releases/tag/3.1.5'
  - url: 'https://lists.debian.org/debian-lts-announce/2025/04/msg00022.html'
  - url: >-
      https://security.access.redhat.com/data/csaf/v2/vex/2024/cve-2024-56326.json
  - url: 'https://access.redhat.com/security/cve/CVE-2024-56326'
  - url: 'https://bugzilla.redhat.com/show_bug.cgi?id=2333856'
  - url: 'https://www.cve.org/CVERecord?id=CVE-2024-56326'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1250'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0721'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0722'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0777'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0341'
  - url: 'https://access.redhat.com/errata/RHBA-2025:1077'
  - url: 'https://access.redhat.com/errata/RHBA-2025:0301'
  - url: 'https://access.redhat.com/errata/RHBA-2025:1597'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1241'
  - url: 'https://access.redhat.com/errata/RHSA-2025:2700'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1710'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1101'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0753'
  - url: 'https://access.redhat.com/errata/RHSA-2025:2399'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1861'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1123'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0875'
  - url: 'https://access.redhat.com/errata/RHSA-2024:6121'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0834'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1118'
  - url: 'https://access.redhat.com/errata/RHSA-2025:0842'
  - url: 'https://access.redhat.com/errata/RHSA-2025:1130'
tags:
  - osv
  - pip
  - csaf
  - vex
  - red-hat
epss: 0.00521
epssPercentile: 0.41776
cwe:
  - CWE-94
scores:
  osv: 7.8
  vendor: 6.3
ingestedAt: '2026-07-08T18:25:52.069Z'
---

## Overview

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.

## Affected packages

- `jinja2 < 3.1.5`

## Remediation

Upgrade to a patched release:

- `jinja2 3.1.5`

## Vendor advisories

- **RHSA-2025:1250** · Red Hat · fixed in: Red Hat Enterprise Linux Server (v. 7 ELS) · released 2025-02-10 · [advisory](https://access.redhat.com/errata/RHSA-2025:1250)
- **RHSA-2025:0721** · Red Hat · fixed in: Red Hat Ansible Automation Platform 2.4 for RHEL 8, Red Hat Ansible Automation Platform 2.4 for RHEL 9 · released 2025-01-27 · [advisory](https://access.redhat.com/errata/RHSA-2025:0721)
- **RHSA-2025:0722** · Red Hat · fixed in: Red Hat Ansible Automation Platform 2.4 for RHEL 8 · released 2025-01-27 · [advisory](https://access.redhat.com/errata/RHSA-2025:0722)
- **RHSA-2025:0777** · Red Hat · fixed in: Red Hat Ansible Automation Platform 2.5 for RHEL 8, Red Hat Ansible Automation Platform 2.5 for RHEL 9 · released 2025-01-28 · [advisory](https://access.redhat.com/errata/RHSA-2025:0777)
- **RHSA-2025:0341** · Red Hat · fixed in: Red Hat Ansible Automation Platform 2.5 for RHEL 8 · released 2025-01-15 · [advisory](https://access.redhat.com/errata/RHSA-2025:0341)
- **RHBA-2025:1077** · Red Hat · fixed in: Quay v3 · released 2025-02-06 · [advisory](https://access.redhat.com/errata/RHBA-2025:1077)
- **RHBA-2025:0301** · Red Hat · fixed in: Quay v3 · released 2025-01-20 · [advisory](https://access.redhat.com/errata/RHBA-2025:0301)
- **RHBA-2025:1597** · Red Hat · fixed in: Quay v3 · released 2025-02-24 · [advisory](https://access.redhat.com/errata/RHBA-2025:1597)
- **RHSA-2025:1241** · Red Hat · fixed in: Red Hat OpenShift Container Platform 4.12 · released 2025-02-13 · [advisory](https://access.redhat.com/errata/RHSA-2025:1241)
- **RHSA-2025:2700** · Red Hat · fixed in: Red Hat OpenShift Container Platform 4.13 · released 2025-03-20 · [advisory](https://access.redhat.com/errata/RHSA-2025:2700)
- **RHSA-2025:1710** · Red Hat · fixed in: Red Hat OpenShift Container Platform 4.15 · released 2025-02-27 · [advisory](https://access.redhat.com/errata/RHSA-2025:1710)
- **Red Hat VEX** · Moderate · affected: OpenShift Lightspeed, Red Hat Ansible Automation Platform 2, Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 9, Red Hat Enterprise Linux AI (RHEL AI), Red Hat OpenShift AI (RHOAI), … · no fix planned: Red Hat OpenShift AI (RHOAI), Red Hat OpenShift Container Platform 4, Red Hat Ansible Automation Platform 2, Red Hat Enterprise Linux 6, … · updated 2026-09-06 · [vex](https://security.access.redhat.com/data/csaf/v2/vex/2024/cve-2024-56326.json)
