VAITP Dataset

← Back to the dataset

CVE-2021-21393

Input validation missing in Synapse (before v1.28.0) for third-party identifier confirmation endpoints

  • CVSS 6.5
  • CWE-20 Improper Input Validation
  • Resource Management
  • 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.28.0 Synapse is missing input validation of some parameters on the endpoints used to confirm third-party identifiers could cause excessive use of disk space and memory leading to resource exhaustion. Note that the groups feature is not part of the Matrix specification and the chosen maximum lengths are arbitrary. Not all clients might abide by them. Refer to referenced GitHub security advisory for additional details including workarounds.

CVSS base score
6.5
Published
2021-04-12
OWASP
A04 Insecure Design
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Fixed by upgrading
Yes

Solution

Update Synapse to version 1.28.0 or higher.

Vulnerable code sample

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/confirm_identifier', methods=['POST'])
def confirm_identifier():
    identifier = request.json.get('identifier')
    return jsonify({"status": "success", "identifier": identifier}), 200

if __name__ == '__main__':
    app.run()

Patched code sample

from flask import Flask, request, jsonify

app = Flask(__name__)

MAX_IDENTIFIER_LENGTH = 255

def validate_third_party_identifier(identifier):
    if len(identifier) > MAX_IDENTIFIER_LENGTH:
        raise ValueError(f"Identifier exceeds maximum length of {MAX_IDENTIFIER_LENGTH} characters.")

@app.route('/confirm_identifier', methods=['POST'])
def confirm_identifier():
    try:
        identifier = request.json.get('identifier')
        validate_third_party_identifier(identifier)
        return jsonify({"status": "success", "identifier": identifier}), 200
    except ValueError as e:
        return jsonify({"error": str(e)}), 400
    except Exception as e:
        return jsonify({"error": "An unexpected error occurred."}), 500

if __name__ == '__main__':
    app.run()

Cite this entry

@misc{vaitp:cve202121393,
  title        = {{Input validation missing in Synapse (before v1.28.0) for third-party identifier confirmation endpoints}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2021},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2021-21393},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2021-21393/}}
}
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 ::