CVE-2021-28363
Description
The urllib3 library 1.26.x before 1.26.4 for Python omits SSL certificate validation in some cases involving HTTPS to HTTPS proxies. The initial connection to the HTTPS proxy (if an SSLContext isn't given via proxy_config) doesn't verify the hostname of the certificate. This means certificates for different servers that still validate properly with the default urllib3 SSLContext will be silently accepted.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
urllib3 1.26.x before 1.26.4 fails to verify SSL certificates for HTTPS proxies when no custom SSLContext is provided, allowing man-in-the-middle attacks.
Root
Cause
urllib3 prior to version 1.26.4 omitted SSL certificate hostname verification when establishing connections to HTTPS proxies if a custom SSLContext was not supplied via the proxy_config parameter. The default SSLContext validates certificates against their issuer but does not check that the certificate's subject matches the proxy's hostname. This means any certificate that is otherwise valid (e.g., issued by a trusted CA for a different domain) is silently accepted for the proxy connection [1][2].
Exploitation
The vulnerability can be exploited by an attacker who controls or intercepts traffic to the HTTPS proxy. By presenting a certificate that is valid for a different server (but still passes default validation), the attacker can impersonate the proxy. No additional authentication or network position is required beyond the ability to perform a man-in-the-middle (MITM) attack on the proxy connection [2][3].
Impact
Successful exploitation allows an attacker to intercept, decrypt, and modify traffic between the client and the ultimate HTTPS server. This could lead to exposure of sensitive data, credential theft, or injection of malicious content. The impact is limited to scenarios where HTTPS-to-HTTPS proxy connections are used with urllib3 without custom SSLContext configuration [2].
Mitigation
The issue is fixed in urllib3 version 1.26.4 [3]. Users are strongly advised to upgrade. For those unable to upgrade immediately, a workaround is to provide an explicit SSLContext that performs hostname verification via the proxy_config parameter [1][2]. No active exploitation in the wild has been reported as of the publication date.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
urllib3PyPI | >= 1.26.0, < 1.26.4 | 1.26.4 |
Affected products
2- Python/urllib3description
Patches
18d65ea1ecf6eMerge pull request from GHSA-5phf-pp7p-vc2r
3 files changed · +37 −0
src/urllib3/connection.py+4 −0 modified@@ -490,6 +490,10 @@ def _connect_tls_proxy(self, hostname, conn): self.ca_cert_dir, self.ca_cert_data, ) + # By default urllib3's SSLContext disables `check_hostname` and uses + # a custom check. For proxies we're good with relying on the default + # verification. + ssl_context.check_hostname = True # If no cert was provided, use only the default options for server # certificate validation
test/conftest.py+11 −0 modified@@ -64,6 +64,17 @@ def no_san_server(tmp_path_factory): yield cfg +@pytest.fixture +def no_localhost_san_server(tmp_path_factory): + tmpdir = tmp_path_factory.mktemp("certs") + ca = trustme.CA() + # non localhost common name + server_cert = ca.issue_cert(u"example.com") + + with run_server_in_thread("https", "localhost", tmpdir, ca, server_cert) as cfg: + yield cfg + + @pytest.fixture def ip_san_server(tmp_path_factory): tmpdir = tmp_path_factory.mktemp("certs")
test/with_dummyserver/test_proxy_poolmanager.py+22 −0 modified@@ -543,3 +543,25 @@ def test_basic_ipv6_proxy(self): r = http.request("GET", "%s/" % self.https_url) assert r.status == 200 + + +class TestHTTPSProxyVerification: + @onlyPy3 + def test_https_proxy_hostname_verification(self, no_localhost_san_server): + bad_server = no_localhost_san_server + bad_proxy_url = "https://%s:%s" % (bad_server.host, bad_server.port) + + # An exception will be raised before we contact the destination domain. + test_url = "testing.com" + with proxy_from_url(bad_proxy_url, ca_certs=bad_server.ca_certs) as https: + with pytest.raises(MaxRetryError) as e: + https.request("GET", "http://%s/" % test_url) + assert isinstance(e.value.reason, SSLError) + assert "hostname 'localhost' doesn't match" in str(e.value.reason) + + with pytest.raises(MaxRetryError) as e: + https.request("GET", "https://%s/" % test_url) + assert isinstance(e.value.reason, SSLError) + assert "hostname 'localhost' doesn't match" in str( + e.value.reason + ) or "Hostname mismatch" in str(e.value.reason)
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
19- github.com/advisories/GHSA-5phf-pp7p-vc2rghsaADVISORY
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/4S65ZQVZ2ODGB52IC7VJDBUK4M5INCXL/mitrevendor-advisory
- nvd.nist.gov/vuln/detail/CVE-2021-28363ghsaADVISORY
- security.gentoo.org/glsa/202107-36ghsavendor-advisoryWEB
- security.gentoo.org/glsa/202305-02ghsavendor-advisoryWEB
- github.com/pypa/advisory-database/tree/main/vulns/urllib3/PYSEC-2021-59.yamlghsaWEB
- github.com/pypa/advisory-db/tree/main/vulns/urllib3/PYSEC-2021-59.yamlghsaWEB
- github.com/urllib3/urllib3/blob/main/CHANGES.rstghsaWEB
- github.com/urllib3/urllib3/commit/8d65ea1ecf6e2cdc27d42124e587c1b83a3118b0ghsaWEB
- github.com/urllib3/urllib3/commits/mainghsaWEB
- github.com/urllib3/urllib3/releases/tag/1.26.4ghsaWEB
- github.com/urllib3/urllib3/security/advisories/GHSA-5phf-pp7p-vc2rghsaWEB
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/4S65ZQVZ2ODGB52IC7VJDBUK4M5INCXLghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4S65ZQVZ2ODGB52IC7VJDBUK4M5INCXLghsaWEB
- pypi.org/project/urllib3/1.26.4ghsaWEB
- security.netapp.com/advisory/ntap-20240621-0007ghsaWEB
- www.oracle.com/security-alerts/cpuoct2021.htmlghsaWEB
- pypi.org/project/urllib3/1.26.4/mitre
- security.netapp.com/advisory/ntap-20240621-0007/mitre
News mentions
0No linked articles in our index yet.