CVE-2020-26708
XXE in requests-xml v0.2.3: Allows code execution via malicious XML
- CVSS 7.5
- CWE-611 Improper Restriction of XML External Entity Reference
- Input Validation and Sanitization
- Remote
requests-xml v0.2.3 was discovered to contain an XML External Entity Injection (XXE) vulnerability which allows attackers to execute arbitrary code via a crafted XML file.
- CVSS base score
- 7.5
- Published
- 2023-06-29
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- requests-xml
- Fixed by upgrading
- Yes
Solution
Update requests-xml to version 0.2.4 or higher.
Vulnerable code sample
import xml.etree.ElementTree as ET
def vulnerable_parse(xml_string):
# This function is vulnerable to XXE attacks
return ET.fromstring(xml_string)
# Example of a crafted XML input that could exploit the vulnerability
xml_input = """<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<root>
<data>&xxe;</data>
</root>"""
parsed_xml = vulnerable_parse(xml_input)
print(parsed_xml)Patched code sample
import xml.etree.ElementTree as ET
def safe_parse(xml_string):
# Parse the XML string safely without allowing external entity expansion
parser = ET.XMLParser()
parser.entity = {}
return ET.fromstring(xml_string, parser=parser)
# Example usage
xml_input = """<root>
<data>Some data</data>
</root>"""
parsed_xml = safe_parse(xml_input)
print(parsed_xml)Cite this entry
@misc{vaitp:cve202026708,
title = {{XXE in requests-xml v0.2.3: Allows code execution via malicious XML}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-26708},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-26708/}}
}
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 ::
