CVE-2021-21273
Synapse Matrix server IP address restriction issue
- CVSS 6.1
- CWE-601 URL Redirection to Untrusted Site ('Open Redirect')
- Configuration Issues
- Remote
Synapse is a Matrix reference homeserver written in python (pypi package matrix-synapse). Matrix is an ecosystem for open federated Instant Messaging and VoIP. In Synapse before version 1.25.0, requests to user provided domains were not restricted to external IP addresses when calculating the key validity for third-party invite events and sending push notifications. This could cause Synapse to make requests to internal infrastructure. The type of request was not controlled by the user, although limited modification of request bodies was possible. For the most thorough protection server administrators should remove the deprecated `federation_ip_range_blacklist` from their settings after upgrading to Synapse v1.25.0 which will result in Synapse using the improved default IP address restrictions. See the new `ip_range_blacklist` and `ip_range_whitelist` settings if more specific control is necessary.
- CVSS base score
- 6.1
- Published
- 2021-02-26
- OWASP
- A10 Server Side Request Forgery (SSRF)
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Configuration Issues
- Subcategory
- Server-Side Request Forgery (SSRF)
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Fixed by upgrading
- Yes
Solution
Update Synapse to version 1.25.0 or higher.
Vulnerable code sample
def handle_third_party_invite(event, user_ip):
request_url = event['invite_url']
response = make_request_to_url(request_url, event['request_body'])
print("Invite processed with response:", response)
def make_request_to_url(url, body):
return "Response from {}".format(url)Patched code sample
import ipaddress
def is_ip_allowed(ip, allowed_ranges):
ip_obj = ipaddress.ip_address(ip)
for ip_range in allowed_ranges:
if ip_obj in ipaddress.ip_network(ip_range):
return True
return False
def handle_third_party_invite(event, user_ip):
allowed_ip_ranges = [
'192.0.2.0/24',
'203.0.113.0/24'
]
if not is_ip_allowed(user_ip, allowed_ip_ranges):
raise ValueError("IP address not allowed for this request.")
print("Invite processed successfully.")Cite this entry
@misc{vaitp:cve202121273,
title = {{Synapse Matrix server IP address restriction issue}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-21273},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-21273/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
