Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS1wNmh3LXdtNTktM2c1Z84AA0-Q
Sydent does not verify email server certificates
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
- 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.
- 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:
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 [email protected].
Permalink: https://github.com/advisories/GHSA-p6hw-wm59-3g5gJSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1wNmh3LXdtNTktM2c1Z84AA0-Q
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: 9 months ago
Updated: 6 months ago
CVSS Score: 9.3
CVSS vector: CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N
Identifiers: GHSA-p6hw-wm59-3g5g, CVE-2023-38686
References:
- https://github.com/matrix-org/sydent/security/advisories/GHSA-p6hw-wm59-3g5g
- https://github.com/python/cpython/issues/91826
- https://github.com/matrix-org/sydent/pull/574
- https://github.com/matrix-org/sydent/commit/1cd748307c6b168b66154e6c4db715d4b9551261
- https://docs.python.org/3/library/ssl.html?highlight=ssl#security-considerations
- https://github.com/matrix-org/sydent/releases/tag/v2.5.6
- https://peps.python.org/pep-0476/
- https://nvd.nist.gov/vuln/detail/CVE-2023-38686
- https://github.com/pypa/advisory-database/tree/main/vulns/matrix-sydent/PYSEC-2023-139.yaml
- https://github.com/advisories/GHSA-p6hw-wm59-3g5g
Blast Radius: 0.0
Affected Packages
pypi:matrix-sydent
Dependent packages: 0Dependent repositories: 1
Downloads: 129 last month
Affected Version Ranges: < 2.5.6
Fixed in: 2.5.6
All affected versions: 2.0.0, 2.0.1, 2.1.0, 2.2.0, 2.3.0, 2.4.0, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5
All unaffected versions: 2.5.6, 2.6.0, 2.6.1