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
yaml email: tlsmode: "TLS" # or the legacy value "SSL"
in its config file. Alternatively it can be configured to use Opportunistic TLS by setting
yaml 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 https://github.com/matrix-org/sydent/pull/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:
yaml email: smtphost: "localhost" # Assuming there is no SMTP server listening on localhost
References
- https://github.com/matrix-org/sydent/pull/574 implements the fix. - https://github.com/matrix-org/sydent/releases/tag/v2.5.6 is the release including this fix. - https://docs.python.org/3/library/ssl.html?highlight=ssl#security-considerations details the best-practice advice on how to use the standard library smtp module safely. - https://peps.python.org/pep-0476/ (accepted) proposed enabling TLS certificate verification by default in standard library HTTP clients. - https://github.com/python/cpython/issues/91826 discusses enabling TLS certificate verification by default in the Python standard library, for SMTP and other protocols.
For more information
If you have any questions or comments about this advisory, e-mail us at security@matrix.org.
Impact
Sydent can be induced to send HTTP GET requests to internal systems, due to lack of parameter validation or IP address blacklisting.
It is not possible to exfiltrate data or control request headers, but it might be possible to use the attack to perform an internal port enumeration.
Patches
Fixed in 9e57334, 8936925, 3d531ed, 0f00412
Workarounds
A potential workaround would be to use a firewall to ensure that Sydent cannot reach internal HTTP resources.
For more information
If you have any questions or comments about this advisory, email us at security@matrix.org.
Impact
A malicious user could abuse Sydent to send out arbitrary emails from the Sydent email address. This could be used to construct plausible phishing emails, for example.
Patches
Fixed in 4469d1d, 6b405a8, 65a6e91.
Note that these patches include changes to the default email templates. If these templates have been locally modified, they must also be updated.
For more information
If you have any questions or comments about this advisory, email us at security@matrix.org.
Impact
Sydent does not limit the size of requests it receives from HTTP clients. A malicious user could send an HTTP request with a very large body, leading to disk space exhaustion and denial of service.
Sydent also does not limit response size for requests it makes to remote Matrix homeservers. A malicious homeserver could return a very large response, again leading to memory exhaustion and denial of service.
This affects any server which accepts registration requests from untrusted clients.
Patches
Patched by 89071a1, 0523511, f56eee3.
Workarounds
Request sizes can be limited in an HTTP reverse-proxy.
There are no known workarounds for the problem with overlarge responses.
For more information
If you have any questions or comments about this advisory, email us at security@matrix.org.
Impact
Missing input validation of some parameters on the endpoints used to confirm third-party identifiers could cause excessive use of disk space and memory leading to resource exhaustion.
Patches
Fixed by 3175fd3.
For more information
If you have any questions or comments about this advisory, email us at security@matrix.org.
An issue was discovered in Matrix Sydent before 1.0.3 and Synapse before 0.99.3.1. Random number generation is mishandled, which makes it easier for attackers to predict a Sydent authentication token or a Synapse random ID.
util/emailutils.py in Matrix Sydent before 1.0.2 mishandles registration restrictions that are based on e-mail domain, if the allowedlocal3pids 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.