GHSA-4822-jvwx-w47h CVE-2022-41952 PYSEC-2026-663
Uncontrolled Resource Consumption in Matrix Synapse
- Severity
- 5.3 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 0.94%
- Chance of exploitation in the next 30 days. Higher than 60.87% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-400 Uncontrolled Resource Consumption
- CWE-772 Missing Release of Resource after Effective Lifetime
- Fix
1.53.0- Upgrade matrix-synapse to this version or later
Description
Impact
Synapse before 1.52.0 with URL preview functionality enabled will attempt to generate URL previews for media stream URLs without properly limiting connection time. Connections will only be terminated after max_spider_size (default: 10M) bytes have been downloaded, which can in some cases lead to long-lived connections towards the streaming media server (for instance, Icecast).
This can cause excessive traffic and connections toward such servers if their stream URL is, for example, posted to a large room with many Synapse instances with URL preview enabled.
Patches
1.52.0 implements a timeout mechanism which will terminate URL preview connections after 30 seconds. Since generating URL previews for media streams is not supported and always fails, 1.53.0 additionally implements an allow list for content types for which Synapse will even attempt to generate a URL preview.
We recommend upgrading to 1.53.0 to fully resolve the issue.
Workarounds
Turn off URL preview functionality by setting url_preview_enabled: false in the Synapse configuration file.
References
- Patch (timeout): https://github.com/matrix-org/synapse/pull/11784
- Patch (content type allow list): https://github.com/matrix-org/synapse/pull/11936
For more information
If you have any questions or comments about this advisory, e-mail us at security@matrix.org.
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| matrix-synapse | < 1.53.0 |
1.53.0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
matrix-synapse PyPI → 1.53.0
- pip
pip install --upgrade "matrix-synapse>=1.53.0"- poetry
poetry add "matrix-synapse>=1.53.0"- uv
uv add "matrix-synapse>=1.53.0"
Severity breakdown
CVSS 3.1 5.3
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Weakness
CWE-400: Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource.
How to prevent it
- Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
- Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
- Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
- Implementation: Ensure that all failures in resource allocation place the system into a safe posture.
CWE-772: Missing Release of Resource after Effective Lifetime
The product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.
How to prevent it
- Requirements: Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, languages such as Java, Ruby, and Lisp perform automatic garbage collection that releases memory for objects that have been deallocated.
- Implementation: It is good practice to be responsible for freeing all resources you allocate and to be consistent with how and where you free resources in a function. If you allocate resources that you intend to free upon completion of the function, you must be sure to free the resources at all exit points for that function including error conditions.
- Operation, Architecture and Design: Use resource-limiting settings provided by the operating system or environment. For example, when managing system resources in POSIX, setrlimit() can be used to set limits for certain types of resources, and getrlimit() can determine how many resources are available. However, these functions are not available on all operating systems. When the current levels get close to the maximum that is defined for the application (see CWE-770), then limit the allocation of further resources to privileged users; alternately, begin releasing resources for less-privileged users. While this mitigation may protect the system from attack, it will not necessarily stop attackers from adversely impacting other users. Ensure that the application performs the appropriate error checks and error handling in case resources become unavailable (CWE-703).
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-6qf2-7x63-mm6v Synapse pagination Denial of Service | Low | Also affects matrix-synapse |
| GHSA-8q93-326v-3m7g Synapse CPU starvation (Denial of Service) | Medium | Also affects matrix-synapse |
| GHSA-fh66-fcv5-jjfr Synapse's invalid device keys degrade federation functionality | Medium | Also affects matrix-synapse |
| GHSA-v56r-hwv5-mxg6 Synapse vulnerable to federation denial of service via malformed events | High | Also affects matrix-synapse |
| GHSA-56w4-5538-8v8h Synapse Matrix has a partial room state leak via Sliding Sync | Medium | Also affects matrix-synapse |
| GHSA-vp6v-whfm-rv3g Synapse can be forced to thumbnail unexpected file formats, invoking external, potentially untrustworthy decoders | Critical | Also affects matrix-synapse |
| GHSA-f3r3-h2mq-hx2h Synapse allows a a malformed invite to break the invitee's `/sync` | Medium | Also affects matrix-synapse |
| GHSA-rfq8-j7rh-8hf2 Synapse allows unsupported content types to lead to memory exhaustion | High | Also affects matrix-synapse |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor