Skip to content
Heist/ feed
Back to feed
Medium

Jinja has a sandbox breakout through indirect reference to format method

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2024-56326
Confirmed fixed CVEs
Not specified
Updated in this feed
2 Nov 2026, 16:25 UTC · Revision 1

Source evidence

Jinja has a sandbox breakout through indirect reference to format method

core-osv · Original source

Published 23 Dec 2024, 15:43 UTC

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.

osv:CVE-2024-56326
Complete source record
{
  "id": "c83650cc1d13f6628a3e8f2543ee420dc67889848e2e6771b9621936b7ff8f14",
  "url": "https://osv.dev/vulnerability/CVE-2024-56326",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Jinja has a sandbox breakout through indirect reference to format method",
    "summary": "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.",
    "evidence": "osv:CVE-2024-56326",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2024-56326",
      "aliases": [
        "CVE-2024-56326",
        "GHSA-q2x7-8rv6-6q7h",
        "PYSEC-2026-1475"
      ],
      "metrics": [
        {
          "type": "CVSS_V4",
          "score": "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"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/pallets/jinja",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "877f6e51be8e1765b06d911cfaa9033775f051d1"
                },
                {
                  "fixed": "48b0687e05a5466a91cd5812d604fa37ad0943b4"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:palletsprojects:jinja:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "3.1.5"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "48b0687e05a5466a91cd5812d604fa37ad0943b4"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  },
                  {
                    "range": [
                      {
                        "fixed": "877f6e51be8e1765b06d911cfaa9033775f051d1"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "3.1.5"
                  }
                ]
              }
            }
          ],
          "versions": [
            "3.1.2",
            "3.1.1",
            "3.1.0",
            "3.0.0",
            "3.0.0rc2",
            "3.0.0rc1",
            "3.0.0a1",
            "2.11.0",
            "2.10",
            "2.9",
            "2.8",
            "2.7",
            "2.6",
            "2.5.3",
            "2.5.1",
            "2.5",
            "2.4.1",
            "2.4",
            "2.3",
            "2.2.1",
            "2.2",
            "2.1.1",
            "2.1",
            "2.0",
            "2.0rc1"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-56326.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:20.909710500Z",
      "provider": "osv",
      "references": [
        "https://github.com/pallets/jinja/releases/tag/3.1.5",
        "https://lists.debian.org/debian-lts-announce/2025/04/msg00022.html",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/56xxx/CVE-2024-56326.json",
        "https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-56326",
        "https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-1336",
          "CWE-693"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/56xxx/CVE-2024-56326.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-56326",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 487092,
  "published_at": "2024-12-23T15:43:49.4+00:00"
}