CVE-2023-38686: Matrix sydent Sydent Does Not Verify Email Vulnerability
CRITICALCVE-2023-38686 is a CRITICAL (CVSS 9.3) sydent does not verify email vulnerability (CWE-295: Improper Certificate Validation) affecting Matrix sydent libraries in the PyPI ecosystem. The issue involves sydent does not verify email server certificates. Remediation is available by upgrading affected packages to version 2.5.6.
CVE-2023-38686 at a Glance
Security Impact
CVSS: 9.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N).
How to Fix CVE-2023-38686
To remediate this vulnerability, upgrade all affected Matrix sydent dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install matrix-sydent>=2.5.6
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show matrix-sydent
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2023-38686, inspect your installed packages using pip:
pip show matrix-sydent
Analyze the terminal output to locate any version of Matrix sydent in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.6), your application is affected.
Note: The pip show matrix-sydent command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-295: Improper Certificate Validation, where the product does not validate, or incorrectly validates, a certificate. In Matrix sydent, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2023-38686 Affected Matrix sydent Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
matrix-sydent
|
PyPI |
< 2.5.6
|
2.5.6
|
References
Frequently Asked Questions
What is CVE-2023-38686?
Which Matrix sydent versions are affected?
What version fixes CVE-2023-38686?
Is matrix-sydent affected?
What is the CVSS score of CVE-2023-38686?
What CWE is associated with CVE-2023-38686?
How can I check PyPI dependencies for CVE-2023-38686?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-p6hw-wm59-3g5g",
"modified" : "2023-08-04T18:41:16Z",
"published" : "2023-07-31T22:03:44Z",
"aliases" : [ "CVE-2023-38686" ],
"summary" : "Sydent does not verify email server certificates",
"details" : "## Impact\n\nIf 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](https://en.wikipedia.org/wiki/Man-in-the-middle_attack). Attackers with privileged access to the network can intercept room invitations and address confirmation emails.\n\nCVSS 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](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=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&version=3.1)\n\n_Reported by Martin Schobert, [Pentagrid AG](https://pentagrid.ch/)._\n\n### Details\n\nSydent can be configured to send emails over a TLS-encrypted socket by setting\n\n```yaml\nemail:\n tlsmode: \"TLS\" # or the legacy value \"SSL\"\n```\n\nin its config file. Alternatively it can be configured to use [Opportunistic TLS](https://en.wikipedia.org/wiki/Opportunistic_TLS) by setting\n\n```yaml\nemail:\n tlsmode: \"STARTTLS\"\n```\n\nIn 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.**\n\n### Vulnerability \n\nSydent sends email for two purposes:\n- to inform a third party that they have been invited to a Matrix room by their email address; and\n- to verify that a given Matrix user controls an email address.\n\nTherefore, attackers capable of running a MITM attack can\n\n1. Intercept room invitations sent to an email address. The invitation includes \n - the room ID and its avatar, and\n - the inviter's username, displayname and their avatar, and\n - credentials for a guest Matrix account on the inviter's homeserver.\n2. 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.\n\n\n### Patches\n\nThis is patched in [Sydent 2.5.6](https://github.com/matrix-org/sydent/releases/tag/v2.5.6), see PR https://github.com/matrix-org/sydent/pull/574.\n\nWhen 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.\n\n### Workarounds\n\nOne can ensure Sydent's emails fail to send by setting the configured SMTP server to a loopback or [non-routable](https://datatracker.ietf.org/doc/html/rfc1918#section-3) address under your control which does not have a listening SMTP server. For example:\n\n```yaml\nemail:\n smtphost: \"localhost\" # Assuming there is no SMTP server listening on localhost\n```\n\n### References\n\n- https://github.com/matrix-org/sydent/pull/574 implements the fix.\n- https://github.com/matrix-org/sydent/releases/tag/v2.5.6 is the release including this fix.\n- 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.\n- https://peps.python.org/pep-0476/ (accepted) proposed enabling TLS certificate verification by default in standard library HTTP clients.\n- https://github.com/python/cpython/issues/91826 discusses enabling TLS certificate verification by default in the Python standard library, for SMTP and other protocols.\n\n## For more information\n\nIf you have any questions or comments about this advisory, e-mail us at [security@matrix.org](mailto:security@matrix.org).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "matrix-sydent"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.5.6"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/matrix-org/sydent/security/advisories/GHSA-p6hw-wm59-3g5g"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-38686"
}, {
"type" : "WEB",
"url" : "https://github.com/python/cpython/issues/91826"
}, {
"type" : "WEB",
"url" : "https://github.com/matrix-org/sydent/pull/574"
}, {
"type" : "WEB",
"url" : "https://github.com/matrix-org/sydent/commit/1cd748307c6b168b66154e6c4db715d4b9551261"
}, {
"type" : "WEB",
"url" : "https://docs.python.org/3/library/ssl.html?highlight=ssl#security-considerations"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/matrix-org/sydent"
}, {
"type" : "WEB",
"url" : "https://github.com/matrix-org/sydent/releases/tag/v2.5.6"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/matrix-sydent/PYSEC-2023-139.yaml"
}, {
"type" : "WEB",
"url" : "https://peps.python.org/pep-0476"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-295" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2023-07-31T22:03:44Z",
"nvd_published_at" : "2023-08-04T16:15:10Z"
}
}