CVE-2018-25082
XML external entity reference vulnerability in WeChat SDK Python 0.3.0, fixed in 0.5.5 (patch: e54abadc777715b6dcb545c13214d1)
- CVSS 9.8
- CWE-611 Improper Restriction of XML External Entity Reference
- Input Validation and Sanitization
- Remote
A vulnerability was found in zwczou WeChat SDK Python 0.3.0 and classified as critical. This issue affects the function validate/to_xml. The manipulation leads to xml external entity reference. The attack may be initiated remotely. Upgrading to version 0.5.5 is able to address this issue. The patch is named e54abadc777715b6dcb545c13214d1dea63df6c9. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-223403.
- CVSS base score
- 9.8
- Published
- 2023-03-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
- Arbitrary Code Execution
- Affected component
- zwczou WeChat SDK Python
- Fixed by upgrading
- Yes
Solution
Update zwczou WeChat SDK Python to version 0.5.5 or higher.
Vulnerable code sample
import xml.etree.ElementTree as ET
def to_xml(data):
# Convert data to XML without protection against XXE
root = ET.Element("root")
for key, value in data.items():
child = ET.SubElement(root, key)
child.text = value # Vulnerable to XML External Entity (XXE) attacks
return ET.tostring(root, encoding='unicode')
# Example usage with potential malicious input
data = {
"name": "example",
"value": "<!ENTITY xxe SYSTEM 'http://malicious.site/attack'>"
}
xml_output = to_xml(data)
print(xml_output)Patched code sample
import xml.etree.ElementTree as ET
def safe_to_xml(data):
# Create a new XML element
root = ET.Element("root")
# Populate the XML with safe data
for key, value in data.items():
child = ET.SubElement(root, key)
child.text = str(value)
# Convert the XML element to a string
return ET.tostring(root, encoding='unicode')
# Example usage
data = {
"name": "example",
"value": "This is safe data"
}
xml_output = safe_to_xml(data)
print(xml_output)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.
- 安全修复:防范XML外部实体注入漏洞(XXE) 参考:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_5 (zwczou/weixin-python)
weixin/msg.py · WeixinMsg.parse,weixin/pay.py · WeixinPay.to_dict
Cite this entry
@misc{vaitp:cve201825082,
title = {{XML external entity reference vulnerability in WeChat SDK Python 0.3.0, fixed in 0.5.5 (patch: e54abadc777715b6dcb545c13214d1)}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2018-25082},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2018-25082/}}
}
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 ::
