CVE-2019-10906: Jinja2 Jinja2 Sandbox Escape Vulnerability

HIGH
Advisory Identifier: GHSA-462w-v97r-4m45
CVSS 8.6
CWE-693
Published
Advisory Summary

CVE-2019-10906 is a HIGH (CVSS 8.6) jinja2 sandbox escape vulnerability (CWE-693: Protection Mechanism Failure) affecting Jinja2 libraries in the PyPI ecosystem. The issue involves jinja2 sandbox escape via string formatting. Remediation is available by upgrading affected packages to version 2.10.1.

CVE-2019-10906 at a Glance

CVE Identifier CVE-2019-10906
GHSA Identifier GHSA-462w-v97r-4m45
Severity HIGH
CVSS v3.1 Base Score 8.6
CWE Classification CWE-693: Protection Mechanism Failure
Affected Product Jinja2
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2019-10906

To remediate this vulnerability, upgrade all affected Jinja2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Jinja2 fixed: 2.10.1
pip install Jinja2>=2.10.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Jinja2

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2019-10906, inspect your installed packages using pip:

pip show Jinja2

Analyze the terminal output to locate any version of Jinja2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.10.1), your application is affected.

Note: The pip show Jinja2 command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-693: Protection Mechanism Failure, where the product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. In Jinja2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

In Pallets Jinja before 2.10.1, `str.format_map` allows a sandbox escape. The sandbox is used to restrict what code can be evaluated when rendering untrusted, user-provided templates. Due to the way string formatting works in Python, the `str.format_map` method could be used to escape the sandbox. This issue was previously addressed for the `str.format` method in Jinja 2.8.1, which discusses the issue in detail. However, the less-common `str.format_map` method was overlooked. This release applies the same sandboxing to both methods. If you cannot upgrade Jinja, you can override the `is_safe_attribute` method on the sandbox and explicitly disallow the `format_map` method on string objects.

CVE-2019-10906 Affected Jinja2 Versions

1 component(s)
Fixed Versions:
2.10.1
Product / Package Ecosystem Affected Versions Fixed Version
Jinja2
PyPI
< 2.10.1
2.10.1

References

NVD — CVE-2019-10906 NVD
https://nvd.nist.gov/vuln/detail/CVE-2019-10906
usn.ubuntu.com/4011-2 WEB
https://usn.ubuntu.com/4011-2
usn.ubuntu.com/4011-1 WEB
https://usn.ubuntu.com/4011-1
palletsprojects.com/blog/jinja-2-10-1-r... WEB
https://palletsprojects.com/blog/jinja-2-10-1-released
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/TS7IVZAJBWOHNRDMFJDIZVFCMRP6YIUQ
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QCDYIS254EJMBNWOG4S5QY6AOTOR4TZU
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DSW3QZMFVVR7YE3UT4YRQA272TYAL5AF
lists.apache.org/thread.html/f0c4a03... WEB
https://lists.apache.org/thread.html/f0c4a03418bcfe70c539c5dbaf99c04c98da13bfa1d3266f08564316@%3Ccommits.airflow.apache.org%3E
lists.apache.org/thread.html/b2380d1... WEB
https://lists.apache.org/thread.html/b2380d147b508bbcb90d2cad443c159e63e12555966ab4f320ee22da@%3Ccommits.airflow.apache.org%3E
lists.apache.org/thread.html/7f39f01... WEB
https://lists.apache.org/thread.html/7f39f01392d320dfb48e4901db68daeece62fd60ef20955966739993@%3Ccommits.airflow.apache.org%3E
lists.apache.org/thread.html/57673a7... WEB
https://lists.apache.org/thread.html/57673a78c4d5c870d3f21465c7e2946b9f8285c7c57e54c2ae552f02@%3Ccommits.airflow.apache.org%3E
lists.apache.org/thread.html/46c055e... WEB
https://lists.apache.org/thread.html/46c055e173b52d599c648a98199972dbd6a89d2b4c4647b0500f2284@%3Cdevnull.infra.apache.org%3E
lists.apache.org/thread.html/320441d... WEB
https://lists.apache.org/thread.html/320441dccbd9a545320f5f07306d711d4bbd31ba43dc9eebcfc602df@%3Cdevnull.infra.apache.org%3E
lists.apache.org/thread.html/2b52b9c... WEB
https://lists.apache.org/thread.html/2b52b9c8b9d6366a4f1b407a8bde6af28d9fc73fdb3b37695fd0d9ac@%3Cdevnull.infra.apache.org%3E
lists.apache.org/thread.html/09fc842... WEB
https://lists.apache.org/thread.html/09fc842ff444cd43d9d4c510756fec625ef8eb1175f14fd21de2605f@%3Cdevnull.infra.apache.org%3E
Jinja2 Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/jinja2/PYSEC-2019-217.yaml
Jinja2 Source Repository REPOSITORY
https://github.com/pallets/jinja
GitHub Advisory / Wiki ADVISORY
https://github.com/advisories/GHSA-462w-v97r-4m45
access.redhat.com/errata/rhsa-2019:13... WEB
https://access.redhat.com/errata/RHSA-2019:1329
access.redhat.com/errata/rhsa-2019:12... WEB
https://access.redhat.com/errata/RHSA-2019:1237
access.redhat.com/errata/rhsa-2019:11... WEB
https://access.redhat.com/errata/RHSA-2019:1152
Jinja2 Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2019-05/msg00030.html
Jinja2 Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2019-06/msg00064.html

Frequently Asked Questions

What is CVE-2019-10906?
CVE-2019-10906 is a security vulnerability in Jinja2 involving Jinja2 sandbox escape via string formatting under CWE-693: Protection Mechanism Failure.
Which Jinja2 versions are affected?
Affected versions include releases prior to 2.10.1 across affected packages: Jinja2.
What version fixes CVE-2019-10906?
Upgrading to 2.10.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Jinja2 affected?
Yes, Jinja2 is affected in releases prior to 2.10.1. Upgrade your dependency to 2.10.1 or later.
What is the CVSS score of CVE-2019-10906?
CVE-2019-10906 has a CVSS v3.1 base score of 8.6 (HIGH) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2019-10906?
CVE-2019-10906 is classified under CWE-693: Protection Mechanism Failure (The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.).
How can I check PyPI dependencies for CVE-2019-10906?
Run the dependency tree command: 'pip show Jinja2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-462w-v97r-4m45",
  "modified" : "2024-09-24T20:49:55Z",
  "published" : "2019-04-10T14:30:24Z",
  "aliases" : [ "CVE-2019-10906" ],
  "summary" : "Jinja2 sandbox escape via string formatting",
  "details" : "In Pallets Jinja before 2.10.1, `str.format_map` allows a sandbox escape.\n\nThe sandbox is used to restrict what code can be evaluated when rendering untrusted, user-provided templates. Due to the way string formatting works in Python, the `str.format_map` method could be used to escape the sandbox.\n\nThis issue was previously addressed for the `str.format` method in Jinja 2.8.1, which discusses the issue in detail. However, the less-common `str.format_map` method was overlooked. This release applies the same sandboxing to both methods.\n\nIf you cannot upgrade Jinja, you can override the `is_safe_attribute` method on the sandbox and explicitly disallow the `format_map` method on string objects.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Jinja2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.10.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-10906"
  }, {
    "type" : "WEB",
    "url" : "https://usn.ubuntu.com/4011-2"
  }, {
    "type" : "WEB",
    "url" : "https://usn.ubuntu.com/4011-1"
  }, {
    "type" : "WEB",
    "url" : "https://palletsprojects.com/blog/jinja-2-10-1-released"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/TS7IVZAJBWOHNRDMFJDIZVFCMRP6YIUQ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QCDYIS254EJMBNWOG4S5QY6AOTOR4TZU"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DSW3QZMFVVR7YE3UT4YRQA272TYAL5AF"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/f0c4a03418bcfe70c539c5dbaf99c04c98da13bfa1d3266f08564316@%3Ccommits.airflow.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/b2380d147b508bbcb90d2cad443c159e63e12555966ab4f320ee22da@%3Ccommits.airflow.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/7f39f01392d320dfb48e4901db68daeece62fd60ef20955966739993@%3Ccommits.airflow.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/57673a78c4d5c870d3f21465c7e2946b9f8285c7c57e54c2ae552f02@%3Ccommits.airflow.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/46c055e173b52d599c648a98199972dbd6a89d2b4c4647b0500f2284@%3Cdevnull.infra.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/320441dccbd9a545320f5f07306d711d4bbd31ba43dc9eebcfc602df@%3Cdevnull.infra.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/2b52b9c8b9d6366a4f1b407a8bde6af28d9fc73fdb3b37695fd0d9ac@%3Cdevnull.infra.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/09fc842ff444cd43d9d4c510756fec625ef8eb1175f14fd21de2605f@%3Cdevnull.infra.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/jinja2/PYSEC-2019-217.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pallets/jinja"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-462w-v97r-4m45"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2019:1329"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2019:1237"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2019:1152"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2019-05/msg00030.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2019-06/msg00064.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-693" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-06-16T20:57:35Z",
    "nvd_published_at" : "2019-04-07T00:29:00Z"
  }
}