# CVE-2023-38686: Sydent does not verify email server certificates

> Sydent fails to verify SMTP certificates when TLS is enabled, allowing network attackers to intercept emails via man-in-the-middle attacks.

- **Severity:** Critical 9.3 (`CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Aug 2023
- **Updated:** 8 Oct 2024
- **Also known as:** GHSA-p6hw-wm59-3g5g, PYSEC-2023-139, UBUNTU-CVE-2023-38686

## What is CVE-2023-38686?

CVE-2023-38686 is a critical vulnerability in matrix-org sydent, published on 4 Aug 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official 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.

Weakness: CWE-295 (Improper Certificate Validation)

## Which versions are affected by CVE-2023-38686?

3 open source packages ship an affected version, including matrix-sydent. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `matrix-sydent` | PyPI | All versions | 2.5.6 |
| `matrix-sydent` | PyPI | All versions | 2.5.6 |
| `matrix-sydent` | PyPI | All versions | 2.5.6 |

Products: Matrix Sydent.

## How do I fix CVE-2023-38686?

Upgrade matrix-sydent to 2.5.6 or later.

## Is CVE-2023-38686 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-38686 exists.

## Other vulnerabilities in matrix-org sydent

- [CVE-2021-29431](https://insights.sbomify.com/CVE-2021-29431/): SSRF in Sydent due to missing validation of hostnames (high 7.7)
- [CVE-2021-29430](https://insights.sbomify.com/CVE-2021-29430/): Denial of service attack via memory exhaustion (high 7.5)
- [CVE-2019-11842](https://insights.sbomify.com/CVE-2019-11842/): matrix-sydent and matrix-synapse Use Cryptographically Weak PRNG (high 7.5)
- [CVE-2019-11340](https://insights.sbomify.com/CVE-2019-11340/): Matrix Sydent mishandles emails (medium 5.9)
- [CVE-2021-29432](https://insights.sbomify.com/CVE-2021-29432/): Malicious users could control the content of invitation emails (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-38686 and fix it if it is affected.

What it is: CVE-2023-38686 is a critical vulnerability in matrix-org sydent, published on 4 Aug 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-38686 exists.

Affected packages and fixed versions:
- matrix-sydent (PyPI): affected all versions; fixed in 2.5.6
- matrix-sydent (PyPI): affected all versions; fixed in 2.5.6
- matrix-sydent (PyPI): affected all versions; fixed in 2.5.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-38686/ (Markdown: https://insights.sbomify.com/CVE-2023-38686/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-38686
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-38686
- OSV: https://osv.dev/vulnerability/CVE-2023-38686

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-38686/
Summaries are generated and may contain mistakes; the official description above is the record.
