CVE-2021-21330: Aiohttp `aiohttp` Open Redirect Vulnerability (`normalize_path_middleware` Vulnerability

LOW
Advisory Identifier: GHSA-v6wp-4m6f-gcjg
CVSS 3.1
CWE-601
Published
Advisory Summary

CVE-2021-21330 is a LOW (CVSS 3.1) `aiohttp` open redirect vulnerability (`normalize_path_middleware` vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Aiohttp libraries in the PyPI ecosystem. The issue involves `aiohttp` open redirect vulnerability (`normalize_path_middleware` middleware). Remediation is available by upgrading affected packages to version 3.7.4.

CVE-2021-21330 at a Glance

CVE Identifier CVE-2021-21330
GHSA Identifier GHSA-v6wp-4m6f-gcjg
Severity LOW
CVSS v3.1 Base Score 3.1
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Aiohttp
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 3.1

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

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

How to Fix CVE-2021-21330

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

aiohttp fixed: 3.7.4
pip install aiohttp>=3.7.4
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 aiohttp

How to Check if You Are Affected

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

pip show aiohttp

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Aiohttp, 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

### Impact Open redirect vulnerability — a maliciously crafted link to an aiohttp-based web-server could redirect the browser to a different website. It is caused by a bug in the `aiohttp.web_middlewares.normalize_path_middleware` middleware. ### Patches This security problem has been fixed in v3.7.4. Upgrade your dependency as follows: [`pip install aiohttp >= 3.7.4`] ### Workarounds If upgrading is not an option for you, a workaround can be to avoid using `aiohttp.web_middlewares.normalize_path_middleware` in your applications. ### References * [aiohttp @ PyPI] * [GHSA-v6wp-4m6f-gcjg] * [OWASP page on open redirects] ### For more information If you have any questions or comments about this advisory: * Open an issue in the [aiohttp repo](https://github.com/aio-libs/aiohttp/issues/new/choose) * Email us at wk+aio-libs-security@sydorenko.org.ua and/or andrew.svetlov+aio-libs-security@gmail.com Credit: [Jelmer Vernooij] and [Beast Glatisant]. [aiohttp @ PyPI]: https://pypi.org/p/aiohttp [`pip install aiohttp >= 3.7.4`]: https://pypi.org/project/aiohttp/3.7.4/ [GHSA-v6wp-4m6f-gcjg]: https://github.com/aio-libs/aiohttp/security/advisories/GHSA-v6wp-4m6f-gcjg [OWASP page on open redirects]: https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html [Jelmer Vernooij]: https://jelmer.uk [Beast Glatisant]: https://github.com/g147

CVE-2021-21330 Affected Aiohttp Versions

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

References

GitHub Advisory / Wiki ADVISORY
https://github.com/aio-libs/aiohttp/security/advisories/GHSA-v6wp-4m6f-gcjg
NVD — CVE-2021-21330 NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-21330
Security Fix Commit FIX COMMIT
https://github.com/aio-libs/aiohttp/commit/2545222a3853e31ace15d87ae0e2effb7da0c96b
Aiohttp Source Repository REPOSITORY
https://github.com/aio-libs/aiohttp
Aiohttp Source Repository REPOSITORY
https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst#374-2021-02-25
Aiohttp Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/aiohttp/PYSEC-2021-76.yaml
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FU7ENI54JNEK3PHEFGCE46DGMFNTVU6L
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/JN3V7CZJRT4QFCVXB6LDPCJH7NAOFCA5
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FU7ENI54JNEK3PHEFGCE46DGMFNTVU6L
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/JN3V7CZJRT4QFCVXB6LDPCJH7NAOFCA5
pypi.org/project/aiohttp WEB
https://pypi.org/project/aiohttp
Aiohttp Security Information SECURITY
https://security.gentoo.org/glsa/202208-19
Aiohttp Security Information SECURITY
https://www.debian.org/security/2021/dsa-4864

Frequently Asked Questions

What is CVE-2021-21330?
CVE-2021-21330 is a security vulnerability in Aiohttp involving `aiohttp` Open Redirect vulnerability (`normalize_path_middleware` middleware) under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Aiohttp versions are affected?
Affected versions include releases prior to 3.7.4 across affected packages: aiohttp.
What version fixes CVE-2021-21330?
Upgrading to 3.7.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is aiohttp affected?
Yes, aiohttp is affected in releases prior to 3.7.4. Upgrade your dependency to 3.7.4 or later.
What is the CVSS score of CVE-2021-21330?
CVE-2021-21330 has a CVSS v3.1 base score of 3.1 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2021-21330?
CVE-2021-21330 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check PyPI dependencies for CVE-2021-21330?
Run the dependency tree command: 'pip show aiohttp'. 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-v6wp-4m6f-gcjg",
  "modified" : "2024-09-03T21:02:49Z",
  "published" : "2021-02-26T02:11:57Z",
  "aliases" : [ "CVE-2021-21330" ],
  "summary" : "`aiohttp` Open Redirect vulnerability (`normalize_path_middleware` middleware)",
  "details" : "### Impact\n\nOpen redirect vulnerability — a maliciously crafted link to an aiohttp-based web-server could redirect the browser to a different website.\n\nIt is caused by a bug in the `aiohttp.web_middlewares.normalize_path_middleware` middleware.\n\n### Patches\n\nThis security problem has been fixed in v3.7.4. Upgrade your dependency as follows:\n[`pip install aiohttp >= 3.7.4`]\n\n### Workarounds\n\nIf upgrading is not an option for you, a workaround can be to avoid using `aiohttp.web_middlewares.normalize_path_middleware` in your applications.\n\n### References\n\n* [aiohttp @ PyPI]\n* [GHSA-v6wp-4m6f-gcjg]\n* [OWASP page on open redirects]\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in the [aiohttp repo](https://github.com/aio-libs/aiohttp/issues/new/choose)\n* Email us at wk+aio-libs-security@sydorenko.org.ua and/or andrew.svetlov+aio-libs-security@gmail.com\n\nCredit: [Jelmer Vernooij] and [Beast Glatisant].\n\n[aiohttp @ PyPI]: https://pypi.org/p/aiohttp\n[`pip install aiohttp >= 3.7.4`]: https://pypi.org/project/aiohttp/3.7.4/\n[GHSA-v6wp-4m6f-gcjg]: https://github.com/aio-libs/aiohttp/security/advisories/GHSA-v6wp-4m6f-gcjg\n[OWASP page on open redirects]:\nhttps://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html\n\n[Jelmer Vernooij]: https://jelmer.uk\n[Beast Glatisant]: https://github.com/g147",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "aiohttp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.7.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/aio-libs/aiohttp/security/advisories/GHSA-v6wp-4m6f-gcjg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21330"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aio-libs/aiohttp/commit/2545222a3853e31ace15d87ae0e2effb7da0c96b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/aio-libs/aiohttp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst#374-2021-02-25"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/aiohttp/PYSEC-2021-76.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FU7ENI54JNEK3PHEFGCE46DGMFNTVU6L"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/JN3V7CZJRT4QFCVXB6LDPCJH7NAOFCA5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FU7ENI54JNEK3PHEFGCE46DGMFNTVU6L"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/JN3V7CZJRT4QFCVXB6LDPCJH7NAOFCA5"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/aiohttp"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202208-19"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-4864"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-601" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-02-26T02:11:40Z",
    "nvd_published_at" : "2021-02-26T03:15:00Z"
  }
}