CVE-2021-21241: Flask Security Too CSRF Can Expose Users Authentication Vulnerability
HIGHCVE-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
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).
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.
pip install Flask-Security-Too>=3.4.5
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
CVE-2021-21241 Affected Flask Security Too Versions
1 component(s)| 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?
Which Flask Security Too versions are affected?
What version fixes CVE-2021-21241?
Is Flask-Security-Too affected?
What is the CVSS score of CVE-2021-21241?
What CWE is associated with CVE-2021-21241?
How can I check PyPI dependencies for CVE-2021-21241?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}