CVE-2021-23336
Python versions 0 to 3.9.2 vulnerable to Web Cache Poisoning via urllib.parse
- CVSS 5.9
- CWE-444 Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
- Input Validation and Sanitization
- Remote
The python/cpython package versions from 0 and before 3.6.13, from 3.7.0 and before 3.7.10, from 3.8.0 and before 3.8.8, from 3.9.0 and before 3.9.2 are susceptible to Web Cache Poisoning via urllib.parse.parse_qsl and urllib.parse.parse_qs by using a vector called parameter cloaking. When the attacker can separate query parameters using a semicolon (;), they can cause a difference in the interpretation of the request between the proxy (running with the default configuration) and the server. This can result in malicious requests being cached as completely safe ones, as the proxy would usually not see the semicolon as a separator, and therefore would not include it in a cache key of an unkeyed parameter.
- CVSS base score
- 5.9
- Published
- 2021-02-15
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Fixed by upgrading
- Yes
Solution
Upgrade to Python/Cpython version 3.9.2 or later.
Vulnerable code sample
import urllib.parse
def parse_qs(query_string):
return urllib.parse.parse_qs(query_string)
if __name__ == "__main__":
query_string = "param1=value1;param2=value2"
parsed_params = parse_qs(query_string)
print("Parsed parameters:", parsed_params)Patched code sample
import urllib.parse
def parse_qs(query_string):
sanitized_query_string = query_string.replace(';', '&')
return urllib.parse.parse_qs(sanitized_query_string)
if __name__ == "__main__":
query_string = "param1=value1;param2=value2"
parsed_params = parse_qs(query_string)
print("Parsed parameters:", parsed_params)Cite this entry
@misc{vaitp:cve202123336,
title = {{Python versions 0 to 3.9.2 vulnerable to Web Cache Poisoning via urllib.parse}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-23336},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-23336/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
