Skip to content

Sydent does not verify email server certificates

Critical severity GitHub Reviewed Published Jul 31, 2023 in matrix-org/sydent • Updated Nov 10, 2023

Package

pip matrix-sydent (pip)

Affected versions

< 2.5.6

Patched versions

2.5.6

Description

Impact

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.

CVSS 3.1 overall score: 3.3 - AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N/CR:L/IR:L/AR:X/MAV:A/MAC:H/MPR:N/MUI:N/MS:C/MC:L/MI:L/MA:N

Reported by Martin Schobert, Pentagrid AG.

Details

Sydent can be configured to send emails over a TLS-encrypted socket by setting

email:
    tlsmode: "TLS"  # or the legacy value "SSL"

in its config file. Alternatively it can be configured to use Opportunistic TLS by setting

email:
    tlsmode: "STARTTLS"

In both situations, Sydent will encrypt its communication with the SMTP server when sending emails. In affected versions, Sydent will not verify the destination server's certificate.

Vulnerability

Sydent sends email for two purposes:

  • to inform a third party that they have been invited to a Matrix room by their email address; and
  • to verify that a given Matrix user controls an email address.

Therefore, attackers capable of running a MITM attack can

  1. Intercept room invitations sent to an email address. The invitation includes
    • the room ID and its avatar, and
    • the inviter's username, displayname and their avatar, and
    • credentials for a guest Matrix account on the inviter's homeserver.
  2. Intercept address ownership confirmation emails. This would allow the attacker to falsely claim ownership of the indented recipient's Matrix account, if that account was permitted to log in using an email address and no other authentication factors.

Patches

This is patched in Sydent 2.5.6, see PR matrix-org/sydent#574.

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. If you are using self-signed certificates, make sure to copy your Certification Authority certificate, or your self signed certificate if using only one, to the trust store of your operating system.

Workarounds

One can ensure Sydent's emails fail to send by setting the configured SMTP server to a loopback or non-routable address under your control which does not have a listening SMTP server. For example:

email:
    smtphost: "localhost"  # Assuming there is no SMTP server listening on localhost

References

For more information

If you have any questions or comments about this advisory, e-mail us at [email protected].

References

@DMRobertson DMRobertson published to matrix-org/sydent Jul 31, 2023
Published to the GitHub Advisory Database Jul 31, 2023
Reviewed Jul 31, 2023
Published by the National Vulnerability Database Aug 4, 2023
Last updated Nov 10, 2023

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Adjacent
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N

EPSS score

0.051%
(21st percentile)

Weaknesses

CVE ID

CVE-2023-38686

GHSA ID

GHSA-p6hw-wm59-3g5g

Source code

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.