CVE-2023-36632 in Pythoninfo

Summary

by MITRE • 06/25/2023

The legacy email.utils.parseaddr function in Python through 3.11.4 allows attackers to trigger "RecursionError: maximum recursion depth exceeded while calling a Python object" via a crafted argument. This argument is plausibly an untrusted value from an application's input data that was supposed to contain a name and an e-mail address. NOTE: email.utils.parseaddr is categorized as a Legacy API in the documentation of the Python email package. Applications should instead use the email.parser.BytesParser or email.parser.Parser class.

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 07/18/2023

The vulnerability described in CVE-2023-36632 represents a critical recursion flaw within Python's legacy email parsing functionality that can be exploited to cause denial of service conditions. This issue affects Python versions through 3.11.4 and specifically targets the email.utils.parseaddr function, which is part of the email package's legacy API. The vulnerability arises from insufficient input validation and recursion depth checking within the parsing logic, making it susceptible to maliciously crafted input that can trigger infinite recursive calls.

The technical implementation of this vulnerability stems from the parseaddr function's handling of malformed email address strings that contain recursive patterns or excessive nesting structures. When an attacker provides a specially crafted input string that appears to contain a name and email address but contains recursive elements, the function enters an infinite loop of recursive calls. This behavior manifests as a RecursionError exception that terminates the Python process and prevents normal application execution. The vulnerability is particularly dangerous because it can be triggered by untrusted input data that applications might receive from external sources such as user forms, API endpoints, or email messages.

The operational impact of this vulnerability extends beyond simple denial of service conditions to potentially compromise entire application availability and stability. Applications that rely on the email.utils.parseaddr function for processing user-provided email addresses or parsing email headers become vulnerable to attacks that can cause system crashes, resource exhaustion, and service interruption. This vulnerability is especially concerning in web applications, email processing systems, and any software that handles untrusted email input data. The issue is further exacerbated by the fact that the affected function is categorized as a Legacy API, indicating that it may not receive the same level of security scrutiny and maintenance as newer components.

Organizations should immediately migrate away from the legacy email.utils.parseaddr function to use the recommended email.parser.BytesParser or email.parser.Parser classes as specified in the Python documentation. These newer APIs provide better input validation, improved error handling, and more robust parsing capabilities that do not suffer from the recursion issues present in the legacy implementation. The mitigation strategy should include comprehensive code auditing to identify all instances where parseaddr is used, followed by proper input sanitization and validation before any email address processing occurs. Additionally, implementing proper recursion depth limits and timeout mechanisms in application code can provide additional protection against similar vulnerabilities.

This vulnerability aligns with CWE-674, which describes "Uncontrolled Recursion" and falls under the broader category of software security weaknesses that can lead to resource exhaustion and system instability. From an ATT&CK perspective, this vulnerability can be categorized under T1499.004 for "Endpoint Denial of Service" and potentially T1059.007 for "Command and Scripting Interpreter: Python" if attackers leverage this to execute malicious Python code. The vulnerability demonstrates the importance of avoiding legacy APIs in security-sensitive applications and highlights the need for regular security assessments of third-party libraries and built-in functions that may contain undiscovered flaws.

Reservation

06/25/2023

Disclosure

06/25/2023

Moderation

accepted

CPE

ready

Exploit

Download

EPSS

0.00279

KEV

no

Activities

very low

Sources

Do you want to use VulDB in your project?

Use the official API to access entries easily!