CVE-2020-28493: Jinja2 Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-g3rq-g295-4j3m
CVSS 5.3
CWE-400
Published
Advisory Summary

CVE-2020-28493 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Jinja2 libraries in the PyPI ecosystem. The issue involves regular expression denial of service (redos) in jinja2. Remediation is available by upgrading affected packages to version 2.11.3.

CVE-2020-28493 at a Glance

CVE Identifier CVE-2020-28493
GHSA Identifier GHSA-g3rq-g295-4j3m
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Jinja2
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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

How to Fix CVE-2020-28493

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.11.3
pip install Jinja2>=2.11.3
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-2020-28493, 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.11.3), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. 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

This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory.

CVE-2020-28493 Affected Jinja2 Versions

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

References

Frequently Asked Questions

What is CVE-2020-28493?
CVE-2020-28493 is a security vulnerability in Jinja2 involving Regular Expression Denial of Service (ReDoS) in Jinja2 under CWE-400: Uncontrolled Resource Consumption.
Which Jinja2 versions are affected?
Affected versions include releases prior to 2.11.3 across affected packages: Jinja2.
What version fixes CVE-2020-28493?
Upgrading to 2.11.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Jinja2 affected?
Yes, Jinja2 is affected in releases prior to 2.11.3. Upgrade your dependency to 2.11.3 or later.
What is the CVSS score of CVE-2020-28493?
CVE-2020-28493 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2020-28493?
CVE-2020-28493 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check PyPI dependencies for CVE-2020-28493?
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-g3rq-g295-4j3m",
  "modified" : "2024-09-24T20:40:19Z",
  "published" : "2021-03-19T21:28:05Z",
  "aliases" : [ "CVE-2020-28493" ],
  "summary" : "Regular Expression Denial of Service (ReDoS) in Jinja2",
  "details" : "This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Jinja2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.11.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-28493"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/jinja/pull/1343"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/jinja/commit/15ef8f09b659f9100610583938005a7a10472d4d"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-g3rq-g295-4j3m"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pallets/jinja"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pallets/jinja/blob/ab81fd9c277900c85da0c322a2ff9d68a235b2e6/src/jinja2/utils.py%23L20"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/jinja2/PYSEC-2021-66.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PVAKCOO7VBVUBM3Q6CBBTPBFNP5NDXF4"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202107-19"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-PYTHON-JINJA2-1012994"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-13T01:08:09Z",
    "nvd_published_at" : "2021-02-01T20:15:00Z"
  }
}