VAITP Dataset

← Back to the dataset

CVE-2021-21333

Synapse Matrix homeserver HTML injection (pre-1.27.0)

  • CVSS 6.1
  • CWE-79
  • Input Validation and Sanitization
  • Remote

Synapse is a Matrix reference homeserver written in python (pypi package matrix-synapse). Matrix is an ecosystem for open federated Instant Messaging and VoIP. In Synapse before version 1.27.0, the notification emails sent for notifications for missed messages or for an expiring account are subject to HTML injection. In the case of the notification for missed messages, this could allow an attacker to insert forged content into the email. The account expiry feature is not enabled by default and the HTML injection is not controllable by an attacker. This is fixed in version 1.27.0.

CVSS base score
6.1
Published
2021-03-26
OWASP
A03 Injection
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
HTML Injection
Fixed by upgrading
Yes

Solution

Update to Synapse version 1.27.0 or higher.

Vulnerable code sample

def send_notification_email(user_email, message):
    email_body = f"""
    <html>
        <body>
            <p>You have a new message:</p>
            <p>{message}</p>
        </body>
    </html>
    """
    
    # Code to send the email (omitted for brevity)
    # send_email(user_email, email_body)

Patched code sample

import html

def send_notification_email(user_email, message):
    # Sanitize the message to prevent HTML injection
    safe_message = html.escape(message)
    
    email_body = f"""
    <html>
        <body>
            <p>You have a new message:</p>
            <p>{safe_message}</p>
        </body>
    </html>
    """
    
    # Code to send the email (omitted for brevity)
    # send_email(user_email, email_body)

Cite this entry

@misc{vaitp:cve202121333,
  title        = {{Synapse Matrix homeserver HTML injection (pre-1.27.0)}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2021},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2021-21333},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-21333/}}
}
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 ::