CVE-2021-32838: Flask restx Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-3q6g-vf58-7m4g
CVSS 7.5
CWE-400 CWE-1333
Published
Advisory Summary

CVE-2021-32838 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Flask restx libraries in the PyPI ecosystem. The issue involves regular expression denial of service in flask-restx. Remediation is available by upgrading affected packages to version 0.5.1.

CVE-2021-32838 at a Glance

CVE Identifier CVE-2021-32838
GHSA Identifier GHSA-3q6g-vf58-7m4g
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Flask restx
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:H).

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 High (A:H)

How to Fix CVE-2021-32838

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

flask-restx fixed: 0.5.1
pip install flask-restx>=0.5.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 flask-restx

How to Check if You Are Affected

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

pip show flask-restx

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

Note: The pip show flask-restx 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 Flask restx, 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

Flask RESTX contains a regular expression that is vulnerable to [ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS) (Regular Expression Denial of Service) in `email_regex`.

CVE-2021-32838 Affected Flask restx Versions

1 component(s)
Fixed Versions:
0.5.1
Product / Package Ecosystem Affected Versions Fixed Version
flask-restx
PyPI
< 0.5.1
0.5.1

References

Frequently Asked Questions

What is CVE-2021-32838?
CVE-2021-32838 is a security vulnerability in Flask restx involving Regular Expression Denial of Service in flask-restx under CWE-400: Uncontrolled Resource Consumption.
Which Flask restx versions are affected?
Affected versions include releases prior to 0.5.1 across affected packages: flask-restx.
What version fixes CVE-2021-32838?
Upgrading to 0.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is flask-restx affected?
Yes, flask-restx is affected in releases prior to 0.5.1. Upgrade your dependency to 0.5.1 or later.
What is the CVSS score of CVE-2021-32838?
CVE-2021-32838 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-32838?
CVE-2021-32838 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-2021-32838?
Run the dependency tree command: 'pip show flask-restx'. 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-3q6g-vf58-7m4g",
  "modified" : "2024-09-20T17:57:56Z",
  "published" : "2021-09-08T15:41:15Z",
  "aliases" : [ "CVE-2021-32838" ],
  "summary" : "Regular Expression Denial of Service in flask-restx",
  "details" : "Flask RESTX contains a regular expression that is vulnerable to [ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS) (Regular Expression Denial of Service) in `email_regex`.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "flask-restx"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.5.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/python-restx/flask-restx/security/advisories/GHSA-3q6g-vf58-7m4g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32838"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-restx/flask-restx/issues/372"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-restx/flask-restx/commit/bab31e085f355dd73858fd3715f7ed71849656da"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-3q6g-vf58-7m4g"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/flask-restx/PYSEC-2021-325.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/python-restx/flask-restx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-restx/flask-restx/blob/fd99fe11a88531f5f3441a278f7020589f9d2cc0/flask_restx/inputs.py#L51"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/5UCTFVDU3677B5OBGK4EF5NMUPJLL6SQ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QUD6SWZLX52AAZUHDETJ2CDMQGEPGFL3"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/flask-restx"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-09-07T14:24:52Z",
    "nvd_published_at" : "2021-09-20T18:15:00Z"
  }
}