CVE-2020-7655
Netius < 1.17.58: HTTP Request Smuggling due to Transfer encoding parsing error
- CVSS 6.1
- CWE-444 Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
- Input Validation and Sanitization
- Remote
netius prior to 1.17.58 is vulnerable to HTTP Request Smuggling. HTTP pipelining issues and request smuggling attacks might be possible due to incorrect Transfer encoding header parsing which could allow for CL:TE or TE:TE attacks.
- CVSS base score
- 6.1
- Published
- 2020-05-21
- 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)
- Affected component
- netius
- Fixed by upgrading
- Yes
Solution
Update to netius version 1.17.58 or higher.
Vulnerable code sample
from http.server import BaseHTTPRequestHandler, HTTPServer
class VulnerableRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
self.send_response(200)
self.end_headers()
self.wfile.write(b'Received: ' + body)
def parse_request(self):
# Vulnerable parsing of Transfer-Encoding and Content-Length
# This allows for potential CL:TE or TE:TE attacks
return super().parse_request()
def run(server_class=HTTPServer, handler_class=VulnerableRequestHandler, port=8080):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
if __name__ == "__main__":
run()Patched code sample
from http.server import BaseHTTPRequestHandler, HTTPServer
class MyRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
self.send_response(200)
self.end_headers()
self.wfile.write(b'Received: ' + body)
def parse_request(self):
# Ensure correct parsing of Transfer-Encoding and Content-Length
if 'Transfer-Encoding' in self.headers and 'Content-Length' in self.headers:
self.send_error(400, "Bad Request: Cannot use both Transfer-Encoding and Content-Length")
return False
return super().parse_request()
def run(server_class=HTTPServer, handler_class=MyRequestHandler, port=8080):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
if __name__ == "__main__":
run()Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- More secure header naming validation (hivesolutions/netius)
src/netius/common/http.py,src/netius/common/http.py · HTTPParser._parse_headers
Cite this entry
@misc{vaitp:cve20207655,
title = {{Netius < 1.17.58: HTTP Request Smuggling due to Transfer encoding parsing error}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-7655},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-7655/}}
}
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 ::
