CVE-2021-41281: Path Traversal in Matrix Synapse
Summary
CVE-2021-41281: Path traversal in Matrix Synapse. Affects matrix-synapse versions < 1.47.1. Fixed in 1.47.1. How to fix ↓
Also tracked for
- matrix-synapse · Debian:13
The same CVE-2021-41281 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Matrix Synapse is an open-source messaging protocol and server implementation that enables decentralized communication. It allows users to exchange messages, media files, and participate in group chats. The vulnerability identified as CVE-2021-41281 affects instances of Matrix Synapse with the media repository enabled. This vulnerability can be exploited to trick the server into downloading a file from a remote server into an arbitrary directory, potentially outside the media store directory. However, the impact is limited as the last two directories and file name of the path are randomly chosen by Synapse and cannot be controlled by an attacker. Homeservers with the media repository disabled or configured with a federation whitelist are not affected.
Vulnerability Detail
The path traversal vulnerability in Matrix Synapse allows an attacker to manipulate the server into downloading a file from a remote server and saving it in an unintended directory. By exploiting this vulnerability, an attacker could potentially bypass security measures and store malicious files outside the designated media store directory. However, the impact is mitigated by the fact that the last two directories and file name of the path are randomly generated by Synapse and cannot be controlled by the attacker. This limits the potential harm that can be caused.
How To Fix
Latest published version: 1.163.0 as of 22 Oct 2026
pip install --upgrade "matrix-synapse==1.163.0"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
1.47.1
This is the first release that contains the fix.
pip install --upgrade "matrix-synapse==1.47.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
Server administrators using a reverse proxy can implement a workaround by blocking specific endpoints. By blocking the following endpoints, media functionality will be lost but the vulnerability can be mitigated:
- /_matrix/media/r0/download/{serverName}/{mediaId}
- /_matrix/media/r0/download/{serverName}/{mediaId}/{fileName}
- /_matrix/media/r0/thumbnail/{serverName}/{mediaId}
Alternatively, non-containerized deployments can adapt to use the hardened systemd config located at contrib/systemd/override-hardened.conf. This configuration provides additional security measures that can help mitigate the vulnerability.
Conclusion
The path traversal vulnerability in Matrix Synapse can be mitigated by upgrading to version 1.47.1 or later. Server administrators should promptly apply the necessary patches to ensure the security of their Matrix Synapse instance. Additionally, the provided workarounds can be implemented to mitigate the vulnerability in specific deployment scenarios. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for matrix-synapse →
FAQ
Instances of Matrix Synapse with the media repository enabled are affected by this vulnerability. Homeservers with the media repository disabled or configured with a federation whitelist are not affected.
The vulnerability allows an attacker to download a file from a remote server and store it in an arbitrary directory, potentially outside the media store directory. However, the last two directories and file name of the path are randomly generated by Synapse and cannot be controlled by the attacker, limiting the impact.
To fix this vulnerability, server administrators should upgrade their Matrix Synapse installation to version 1.47.1 or later. This update includes patches that address the path traversal issue and enhance the security of the media repository.
Server administrators using a reverse proxy can block specific endpoints to mitigate the vulnerability. Alternatively, non-containerized deployments can adapt to use the hardened systemd config provided by Matrix Synapse.
No, there is no specific reference documentation available for this vulnerability at the moment.
References
Related vulnerabilities
Recent vulnerabilities recorded for matrix-synapse.