VAITP Dataset

← Back to the dataset

CVE-2019-11340

Email domain-based registration restrictions bypass in Matrix Sydent < 1.0.2

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

util/emailutils.py in Matrix Sydent before 1.0.2 mishandles registration restrictions that are based on e-mail domain, if the allowed_local_3pids option is enabled. This occurs because of potentially unwanted behavior in Python, in which an email.utils.parseaddr call on user@bad.example.net@good.example.com returns the user@bad.example.net substring.

CVSS base score
5.9
Published
2019-04-19
OWASP
A04 Insecure Design
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

Update Matrix Sydent to version 1.0.2 or higher.

Vulnerable code sample

from email.utils import parseaddr

def handle_registration(email_str, allowed_domains):
    name, email = parseaddr(email_str)
    domain = email.split('@')[-1]
    
    if domain not in allowed_domains:
        raise ValueError("Email domain not allowed.")
    
    return f"Registration successful for {email}"

allowed_domains = {"good.example.com"}
try:
    print(handle_registration("user@bad.example.net@good.example.com", allowed_domains))
except ValueError as e:
    print(e)

Patched code sample

from email.utils import parseaddr
import re

def handle_registration(email_str, allowed_domains):
    name, email = parseaddr(email_str)
    
    if not re.fullmatch(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}", email):
        raise ValueError("Invalid email format.")
    
    parts = email.split('@')
    if len(parts) != 2:
        raise ValueError("Malformed email address.")
    
    domain = parts[1].lower()
    if domain not in allowed_domains:
        raise ValueError("Email domain not allowed.")
    
    return f"Registration successful for {email}"

allowed_domains = {"good.example.com"}
try:
    print(handle_registration("user@example.net@example.com", allowed_domains))
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve201911340,
  title        = {{Email domain-based registration restrictions bypass in Matrix Sydent < 1.0.2}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-11340},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-11340/}}
}
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 ::