ghsa-q2x7-8rv6-6q7h
Vulnerability from github
Published
2024-12-23 17:56
Modified
2024-12-27 19:10
Summary
Jinja has a sandbox breakout through indirect reference to format method
Details

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.

Show details on source website


{
   affected: [
      {
         database_specific: {
            last_known_affected_version_range: "<= 3.1.4",
         },
         package: {
            ecosystem: "PyPI",
            name: "jinja2",
         },
         ranges: [
            {
               events: [
                  {
                     introduced: "0",
                  },
                  {
                     fixed: "3.1.5",
                  },
               ],
               type: "ECOSYSTEM",
            },
         ],
      },
   ],
   aliases: [
      "CVE-2024-56326",
   ],
   database_specific: {
      cwe_ids: [
         "CWE-693",
      ],
      github_reviewed: true,
      github_reviewed_at: "2024-12-23T17:56:08Z",
      nvd_published_at: "2024-12-23T16:15:07Z",
      severity: "MODERATE",
   },
   details: "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.\n\nTo 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.\n\nJinja'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.",
   id: "GHSA-q2x7-8rv6-6q7h",
   modified: "2024-12-27T19:10:36Z",
   published: "2024-12-23T17:56:08Z",
   references: [
      {
         type: "WEB",
         url: "https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h",
      },
      {
         type: "ADVISORY",
         url: "https://nvd.nist.gov/vuln/detail/CVE-2024-56326",
      },
      {
         type: "WEB",
         url: "https://github.com/pallets/jinja/commit/48b0687e05a5466a91cd5812d604fa37ad0943b4",
      },
      {
         type: "PACKAGE",
         url: "https://github.com/pallets/jinja",
      },
      {
         type: "WEB",
         url: "https://github.com/pallets/jinja/releases/tag/3.1.5",
      },
   ],
   schema_version: "1.4.0",
   severity: [
      {
         score: "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
         type: "CVSS_V3",
      },
      {
         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",
         type: "CVSS_V4",
      },
   ],
   summary: "Jinja has a sandbox breakout through indirect reference to format method",
}


Log in or create an account to share your comment.

Security Advisory comment format.

This schema specifies the format of a comment related to a security advisory.

UUIDv4 of the comment
UUIDv4 of the Vulnerability-Lookup instance
When the comment was created originally
When the comment was last updated
Title of the comment
Description of the comment
The identifier of the vulnerability (CVE ID, GHSA-ID, PYSEC ID, etc.).



Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.