CVE-2021-21333: HTML injection in email and account expiry notifications in matrix-synapse

matrix-synapse Updated 02 Oct 2025

Summary

26/03/2021
Yes i
Moderate
6.1

CVE-2021-21333: HTML injection in email and account expiry notifications. Affects matrix-synapse versions < 1.27.0. Fixed in 1.27.0. How to fix ↓

Also tracked for

The same CVE-2021-21333 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

matrix-synapse is an open-source Python package that provides a reference implementation of the Matrix communication protocol. It is used to create and manage Matrix homeservers, allowing users to communicate securely and in real-time. The package includes features such as missed message notifications and account expiry notifications.

Vulnerability Detail

The vulnerability identified as CVE-2021-21333 involves HTML injection in email and account expiry notifications. When sending notification emails for missed messages or expiring accounts, the package is susceptible to HTML injection. This allows an attacker to insert forged content into the email, potentially leading to various malicious activities. It is important to note that the account expiry feature is not enabled by default, and the HTML injection is not controllable by an attacker.

How To Fix

Latest published version: 1.163.0 as of 22 Oct 2026

pip install --upgrade "matrix-synapse==1.163.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.27.0

This is the first release that contains the fix.

pip install --upgrade "matrix-synapse==1.27.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

For missed messages notifications:

To mitigate the HTML injection vulnerability in missed messages notifications, you can override the notif.html, notif_mail.html, and room.html templates with custom templates that manually escape the variables using Jinja2's escape filter. This can be achieved by modifying the email.template_dir setting.

For account expiry notifications:

  1. If you do not require the account expiry feature, it is recommended to disable it by setting account_validity.enabled to false.

  2. If you still need to use account expiry notifications, you can create a custom template that manually escapes the variables using Jinja2's escape filter. This can be done by overriding the notice_expiry.html template and configuring the email.template_dir setting.

Conclusion

In conclusion, the matrix-synapse package is vulnerable to HTML injection in email and account expiry notifications. To mitigate this vulnerability, it is crucial to update the package to version 1.27.0 or later. Additionally, workarounds such as overriding templates and disabling the account expiry feature can be implemented. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for matrix-synapse →

Share this vulnerability

FAQ

The vulnerability allows an attacker to inject forged content into notification emails, potentially leading to various malicious activities. However, it is important to note that the account expiry feature is not enabled by default, and the HTML injection is not controllable by an attacker.

To fix this vulnerability, update the matrix-synapse package to version 1.27.0 or later. This update includes the necessary patches to address the HTML injection issue.

Yes, there are workarounds available. For missed messages notifications, you can override the relevant templates with custom templates that manually escape the variables. For account expiry notifications, you can disable the feature or create a custom template that escapes the variables.

Yes, you can still use account expiry notifications. If you require this feature, you can create a custom template that manually escapes the variables to mitigate the HTML injection vulnerability.

Yes, the CVSS score for this vulnerability is 6.1.

Related vulnerabilities

Recent vulnerabilities recorded for matrix-synapse.

How To Fix

Latest published version: 1.163.0 as of 22 Oct 2026

pip install --upgrade "matrix-synapse==1.163.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

1.27.0

This is the first release that contains the fix.

pip install --upgrade "matrix-synapse==1.27.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback