CVE-2021-41281
JSON

7.5high

Path traversal in Matrix Synapse

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
1.58% (higher than 76% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-3hfw-x7gx-437cPYSEC-2021-436

Description

Synapse is a package for Matrix homeservers written in Python 3/Twisted. Prior to version 1.47.1, Synapse instances with the media repository enabled can be tricked into downloading a file from a remote server into an arbitrary directory. No authentication is required for the affected endpoint. The last 2 directories and file name of the path are chosen randomly by Synapse and cannot be controlled by an attacker, which limits the impact. Homeservers with the media repository disabled are unaffected. Homeservers with a federation whitelist are also unaffected, since Synapse will check the remote hostname, including the trailing `../`s, against the whitelist. Server administrators should upgrade to 1.47.1 or later. Server administrators using a reverse proxy could, at the expense of losing media functionality, may block the certain endpoints as a workaround. Alternatively, non-containerized deployments can be adapted to use the hardened systemd config.

Affected

Product or packageVersionsReported by
matrix-org synapse< 1.47.1CVE List
matrix-synapse (PyPI)before 1.47.1, before 91f2bd0907f1d05af67166846988e49644eb650cGitHub Advisory Database, PyPA Advisory Database
matrix synapsebefore 1.47.1NVD
fedoraproject fedora34, 35NVD

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N
NVD4.3medium CVSS:2.0AV:N/AC:M/Au:N/C:N/I:P/A:N

Classification

What each source says

CVE List

Synapse is a package for Matrix homeservers written in Python 3/Twisted. Prior to version 1.47.1, Synapse instances with the media repository enabled can be tricked into downloading a file from a remote server into an arbitrary directory. No authentication is required for the affected endpoint. The last 2 directories and file name of the path are chosen randomly by Synapse and cannot be controlled by an attacker, which limits the impact. Homeservers with the media repository disabled are unaffected. Homeservers with a federation whitelist are also unaffected, since Synapse will check the remote hostname, including the trailing `../`s, against the whitelist. Server administrators should upgrade to 1.47.1 or later. Server administrators using a reverse proxy could, at the expense of losing media functionality, may block the certain endpoints as a workaround. Alternatively, non-containerized deployments can be adapted to use the hardened systemd config.

GitHub Advisory Database
Impact

Synapse instances with the media repository enabled can be tricked into downloading a file from a remote server into an arbitrary directory, potentially outside the media store directory.

The last two directories and file name of the path are chosen randomly by Synapse and cannot be controlled by an attacker, which limits the impact.

Homeservers with the media repository disabled are unaffected. Homeservers configured with a federation whitelist are also unaffected.

Patches

Server administrators should upgrade to 1.47.1 or later.

Workarounds

Server administrators using a reverse proxy could, at the expense of losing media functionality, block the following endpoints:

  • /_matrix/media/r0/download/{serverName}/{mediaId}
  • /_matrix/media/r0/download/{serverName}/{mediaId}/{fileName}
  • /_matrix/media/r0/thumbnail/{serverName}/{mediaId}

Alternatively, non-containerized deployments can be adapted to use the hardened systemd config, located at contrib/systemd/override-hardened.conf.

References

n/a

For more information

If you have any questions or comments about this advisory, e-mail us at security@matrix.org.

NVD (es)

Synapse es un paquete para servidores domésticos Matrix escrito en Python 3/Twisted. En versiones anteriores a 1.47.1, las instancias de Synapse con el repositorio de medios habilitado pueden ser engañadas para descargar un archivo de un servidor remoto en un directorio arbitrario. No es requerida autenticación para el endpoint afectado. Los dos últimos directorios y el nombre del archivo de la ruta son elegidos al azar por Synapse y no pueden ser controlados por un atacante, lo que limita el impacto. Los servidores domésticos con el repositorio de medios deshabilitado no están afectados. Los servidores domésticos con una lista blanca de la federación tampoco están afectados, ya que Synapse comprobará el nombre de host remoto, incluyendo el final "../", con la lista blanca. Los administradores de servidores deben actualizar a la versión 1.47.1 o posterior. Los administradores de servidores que usen un proxy inverso podrían, a costa de perder la funcionalidad de los medios de comunicación, bloquear ciertos endpoints como solución. Como alternativa, los despliegues sin contenedores pueden adaptarse para usar la configuración systemd endurecida

References

https://github.com/matrix-org/synapse/security/advisories/GHSA-3hfw-x7gx-437cadvisory, mitigation, third-party-advisory, web
https://github.com/matrix-org/synapse/commit/91f2bd090fix, patch, third-party-advisory, web
https://github.com/matrix-org/synapse/releases/tag/v1.47.1release-notes, third-party-advisory, web
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/N3WY56LCEZ4ZECLWV5KMAXF2PSMUB4F2/vendor-advisory
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EU7QRE55U4IUEDLKT5IYPWL3UXMELFAS/vendor-advisory
https://nvd.nist.gov/vuln/detail/CVE-2021-41281advisory
https://github.com/matrix-org/synapsepackage
https://github.com/pypa/advisory-database/tree/main/vulns/matrix-synapse/PYSEC-2021-436.yamlweb
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/EU7QRE55U4IUEDLKT5IYPWL3UXMELFASweb
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N3WY56LCEZ4ZECLWV5KMAXF2PSMUB4F2web

Sources

SourceRecordLicence
CVE ListCVE-2021-41281 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-3hfw-x7gx-437c changed 2026-07-08CC-BY-4.0
NVDCVE-2021-41281 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-436 changed 2026-02-26CC-BY-4.0