Sydent does not verify email server certificates
Description
Sydent is an identity server for the Matrix communications protocol. Prior to version 2.5.6, if configured to send emails using TLS, Sydent does not verify SMTP servers' certificates. This makes Sydent's emails vulnerable to interception via a man-in-the-middle (MITM) attack. Attackers with privileged access to the network can intercept room invitations and address confirmation emails. This is patched in Sydent 2.5.6. When patching, make sure that Sydent trusts the certificate of the server it is connecting to. This should happen automatically when using properly issued certificates. Those who use self-signed certificates should make sure to copy their Certification Authority certificate, or their self signed certificate if using only one, to the trust store of your operating system. As a workaround, one can ensure Sydent's emails fail to send by setting the configured SMTP server to a loopback or non-routable address under one's control which does not have a listening SMTP server.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
matrix-sydentPyPI | < 2.5.6 | 2.5.6 |
Affected products
1- Range: < 2.5.6
Patches
11cd748307c6bExplicitly create an SSL context when emailing (#574)
2 files changed · +7 −2
changelog.d/574.bugfix+1 −0 added@@ -0,0 +1 @@ +Fix a long-standing issue where Sydent would not verify the configured SMTP server's certificates. See [GHSA-p6hw-wm59-3q5q](https://github.com/matrix-org/sydent/security/advisories/GHSA-p6hw-wm59-3g5g) and [CVE-2023-38686](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-38686). Reported by Martin Schobert, [Pentagrid AG](https://pentagrid.ch). \ No newline at end of file
sydent/util/emailutils.py+6 −2 modified@@ -16,6 +16,7 @@ import logging import random import smtplib +import ssl import string import urllib from html import escape @@ -106,11 +107,14 @@ def sendEmail( ) try: smtp: smtplib.SMTP + # Explicitly create a context, to ensure we verify the server's certificate + # and hostname. + ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH) if mailTLSMode == "SSL" or mailTLSMode == "TLS": - smtp = smtplib.SMTP_SSL(mailServer, mailPort, myHostname) + smtp = smtplib.SMTP_SSL(mailServer, mailPort, myHostname, context=ctx) elif mailTLSMode == "STARTTLS": smtp = smtplib.SMTP(mailServer, mailPort, myHostname) - smtp.starttls() + smtp.starttls(context=ctx) else: smtp = smtplib.SMTP(mailServer, mailPort, myHostname) if mailUsername != "":
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
11- github.com/advisories/GHSA-p6hw-wm59-3g5gghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2023-38686ghsaADVISORY
- docs.python.org/3/library/ssl.htmlghsax_refsource_MISCWEB
- github.com/matrix-org/sydent/commit/1cd748307c6b168b66154e6c4db715d4b9551261ghsax_refsource_MISCWEB
- github.com/matrix-org/sydent/pull/574ghsax_refsource_MISCWEB
- github.com/matrix-org/sydent/releases/tag/v2.5.6ghsax_refsource_MISCWEB
- github.com/matrix-org/sydent/security/advisories/GHSA-p6hw-wm59-3g5gghsax_refsource_CONFIRMWEB
- github.com/pypa/advisory-database/tree/main/vulns/matrix-sydent/PYSEC-2023-139.yamlghsaWEB
- github.com/python/cpython/issues/91826ghsax_refsource_MISCWEB
- peps.python.org/pep-0476ghsaWEB
- peps.python.org/pep-0476/mitrex_refsource_MISC
News mentions
0No linked articles in our index yet.