CVE-2021-21332
Synapse Matrix server XSS vulnerability (fixed in 1.27.0)
- CVSS 8.2
- CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
- 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.27.0, the password reset endpoint served via Synapse was vulnerable to cross-site scripting (XSS) attacks. The impact depends on the configuration of the domain that Synapse is deployed on, but may allow access to cookies and other browser data, CSRF vulnerabilities, and access to other resources served on the same domain or parent domains. This is fixed in version 1.27.0.
- CVSS base score
- 8.2
- Published
- 2021-03-26
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Configuration Issues
- Subcategory
- Cross-Site Scripting (XSS)
- Accessibility scope
- Remote
- Impact
- Information Disclosure
- Fixed by upgrading
- Yes
Solution
Update to Synapse version 1.27.0 or higher.
Vulnerable code sample
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route('/reset_password', methods=['GET', 'POST'])
def reset_password():
if request.method == 'POST':
user_input = request.form['user_input']
return f"Password reset link has been sent to {user_input}"
return render_template_string('''
<form method="post">
<label for="user_input">Enter your email:</label>
<input type="text" id="user_input" name="user_input">
<input type="submit" value="Reset Password">
</form>
''')
if __name__ == '__main__':
app.run()Patched code sample
from flask import Flask, request, render_template_string
import html
app = Flask(__name__)
@app.route('/reset_password', methods=['GET', 'POST'])
def reset_password():
if request.method == 'POST':
user_input = request.form['user_input']
sanitized_input = html.escape(user_input)
return f"Password reset link has been sent to {sanitized_input}"
return render_template_string('''
<form method="post">
<label for="user_input">Enter your email:</label>
<input type="text" id="user_input" name="user_input">
<input type="submit" value="Reset Password">
</form>
''')
if __name__ == '__main__':
app.run()Cite this entry
@misc{vaitp:cve202121332,
title = {{Synapse Matrix server XSS vulnerability (fixed in 1.27.0)}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2021},
note = {VAITP Python Vulnerability Dataset, entry CVE-2021-21332},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-21332/}}
}
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 ::
