VAITP Dataset

← Back to the dataset

CVE-2023-27043

Incorrect parsing of e-mail addresses in Python email module

  • CVSS 5.3
  • CWE-20 Improper Input Validation
  • Input Validation and Sanitization
  • Remote

The email module of Python through 3.11.3 incorrectly parses e-mail addresses that contain a special character. The wrong portion of an RFC2822 header is identified as the value of the addr-spec. In some applications, an attacker can bypass a protection mechanism in which application access is granted only after verifying receipt of e-mail to a specific domain (e.g., only @company.example.com addresses may be used for signup). This occurs in email/_parseaddr.py in recent versions of Python.

CVSS base score
5.3
Published
2023-04-19
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Unauthorized Access
Fixed by upgrading
Yes

Solution

Upgrade to Python version 3.11.4 or newer.

Vulnerable code sample

import email.utils

user_input = input("Enter an email address: ")

name, address = email.utils.parseaddr(user_input)

print(f"Name: {name}")
print(f"Address: {address}")

Patched code sample

from email_validator import validate_email

def check_email_domain(email, domain):
    email_parts = validate_email(email)
    if email_parts.domain == domain:
        return True
    else:
        return False

print(check_email_domain("alice@company.example.com", "company.example.com")) # True
print(check_email_domain("bob@company.example.com", "company.example.com")) # True
print(check_email_domain("charlie@evil.com", "company.example.com")) # False
print(check_email_domain("alice@evil.com<alice@company.example.com>", "company.example.com")) # False

Cite this entry

@misc{vaitp:cve202327043,
  title        = {{Incorrect parsing of e-mail addresses in Python email module}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-27043},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-27043/}}
}
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 ::