CVE-2021-21241: Flask Security Too CSRF Can Expose Users Authentication Vulnerability

HIGH
Advisory Identifier: GHSA-hh7m-rx4f-4vpv
CVSS 7.4
CWE-352
Published
Advisory Summary

CVE-2021-21241 is a HIGH (CVSS 7.4) csrf can expose users authentication vulnerability (CWE-352: Cross-Site Request Forgery (CSRF)) affecting Flask Security Too libraries in the PyPI ecosystem. The issue involves csrf can expose users authentication token. Remediation is available by upgrading affected packages to version 3.4.5.

CVE-2021-21241 at a Glance

CVE Identifier CVE-2021-21241
GHSA Identifier GHSA-hh7m-rx4f-4vpv
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-352: Cross-Site Request Forgery (CSRF)
Affected Product Flask Security Too
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.4

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:R/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 Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2021-21241

To remediate this vulnerability, upgrade all affected Flask Security Too 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-Security-Too fixed: 3.4.5
pip install Flask-Security-Too>=3.4.5
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-Security-Too

How to Check if You Are Affected

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

pip show Flask-Security-Too

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

Note: The pip show Flask-Security-Too command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-352: Cross-Site Request Forgery (CSRF), where the web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. In Flask Security Too, 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

### Issue The /login and /change endpoints can return the authenticated user's authentication token in response to a GET request. Since GET requests aren't protected with a CSRF token, this could lead to a malicious 3rd party site acquiring the authentication token. ### Patches Version 3.4.5 and soon to be released 4.0.0 are patched. ### Workarounds If you aren't using authentication tokens - you can set the SECURITY_TOKEN_MAX_AGE to "0" (seconds) which should make the token unusable. ### References None

CVE-2021-21241 Affected Flask Security Too Versions

1 component(s)
Fixed Versions:
3.4.5
Product / Package Ecosystem Affected Versions Fixed Version
Flask-Security-Too
PyPI
≥ 3.3.0
< 3.4.5
3.4.5

References

Frequently Asked Questions

What is CVE-2021-21241?
CVE-2021-21241 is a security vulnerability in Flask Security Too involving CSRF can expose users authentication token under CWE-352: Cross-Site Request Forgery (CSRF).
Which Flask Security Too versions are affected?
Affected versions include releases prior to 3.4.5 across affected packages: Flask-Security-Too.
What version fixes CVE-2021-21241?
Upgrading to 3.4.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Flask-Security-Too affected?
Yes, Flask-Security-Too is affected in releases prior to 3.4.5. Upgrade your dependency to 3.4.5 or later.
What is the CVSS score of CVE-2021-21241?
CVE-2021-21241 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2021-21241?
CVE-2021-21241 is classified under CWE-352: Cross-Site Request Forgery (CSRF) (The web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor.).
How can I check PyPI dependencies for CVE-2021-21241?
Run the dependency tree command: 'pip show Flask-Security-Too'. 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-hh7m-rx4f-4vpv",
  "modified" : "2024-09-20T17:48:13Z",
  "published" : "2021-01-11T20:38:28Z",
  "aliases" : [ "CVE-2021-21241" ],
  "summary" : "CSRF can expose users authentication token",
  "details" : "### Issue\nThe  /login and /change endpoints can return the authenticated user's authentication token in response to a GET request. Since GET requests aren't protected with a CSRF token, this could lead to a malicious 3rd party site acquiring the authentication token.\n\n### Patches\nVersion 3.4.5 and soon to be released 4.0.0 are patched.\n\n### Workarounds\nIf you aren't using authentication tokens - you can set the SECURITY_TOKEN_MAX_AGE to \"0\" (seconds) which should make the token unusable.\n\n### References\nNone",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Flask-Security-Too"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.3.0"
      }, {
        "fixed" : "3.4.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21241"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/flask-security-too/PYSEC-2021-91.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/Flask-Security-Too"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20210118165844/https://github.com/Flask-Middleware/flask-security/releases/tag/3.4.5"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20210118165958/https://github.com/Flask-Middleware/flask-security/commit/6d50ee9169acf813257c37b75babe9c28e83542a"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20210118170445/https://github.com/Flask-Middleware/flask-security/commit/61d313150b5f620d0b800896c4f2199005e84b1f"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20210118170502/https://github.com/Flask-Middleware/flask-security/security/advisories/GHSA-hh7m-rx4f-4vpv"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20211207005640/https://github.com/Flask-Middleware/flask-security/pull/422"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-352" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-01-11T20:32:44Z",
    "nvd_published_at" : "2021-01-11T21:15:00Z"
  }
}