CVE-2022-31152: Matrix synapse Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-jhjh-776m-4765
CVSS 7.5
CWE-703 CWE-755
Published
Advisory Summary

CVE-2022-31152 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-703: Improper Check or Handling of Exceptional Conditions) affecting Matrix synapse libraries in the PyPI ecosystem. The issue involves denial of service due to incorrect application of event authorization rules. Remediation is available by upgrading affected packages to version 1.62.0rc1.

CVE-2022-31152 at a Glance

CVE Identifier CVE-2022-31152
GHSA Identifier GHSA-jhjh-776m-4765
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-703: Improper Check or Handling of Exceptional Conditions
Affected Product Matrix synapse
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2022-31152

To remediate this vulnerability, upgrade all affected Matrix synapse dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

matrix-synapse fixed: 1.62.0rc1
pip install matrix-synapse>=1.62.0rc1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show matrix-synapse

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2022-31152, inspect your installed packages using pip:

pip show matrix-synapse

Analyze the terminal output to locate any version of Matrix synapse in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.62.0rc1), your application is affected.

Note: The pip show matrix-synapse command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-703: Improper Check or Handling of Exceptional Conditions, where the product does not properly anticipate or handle exceptional conditions that rarely occur during normal operation of the product. In Matrix synapse, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The Matrix specification specifies a list of [event authorization rules](https://spec.matrix.org/v1.3/rooms/v10/#authorization-rules) which must be checked when determining if an event should be accepted into a room. In versions of Synapse up to and including v1.61, some of these rules are not correctly applied. An attacker could craft events which would be accepted by Synapse but not a spec-conformant server, potentially causing divergence in the room state between servers. ### Patches Administrators of homeservers with federation enabled are advised to upgrade to v1.62.0 or higher. ### Workarounds * Federation can be disabled by setting [`federation_domain_whitelist`](https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#federation_domain_whitelist) to an empty list (`[]`). ### References * https://github.com/matrix-org/synapse/pull/13087 * https://github.com/matrix-org/synapse/pull/13088 ### For more information If you have any questions or comments about this advisory, e-mail us at [security@matrix.org](mailto:security@matrix.org).

CVE-2022-31152 Affected Matrix synapse Versions

1 component(s)
Fixed Versions:
1.62.0rc1
Product / Package Ecosystem Affected Versions Fixed Version
matrix-synapse
PyPI
< 1.62.0rc1
1.62.0rc1

References

Frequently Asked Questions

What is CVE-2022-31152?
CVE-2022-31152 is a security vulnerability in Matrix synapse involving Denial of service due to incorrect application of event authorization rules under CWE-703: Improper Check or Handling of Exceptional Conditions.
Which Matrix synapse versions are affected?
Affected versions include releases prior to 1.62.0rc1 across affected packages: matrix-synapse.
What version fixes CVE-2022-31152?
Upgrading to 1.62.0rc1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is matrix-synapse affected?
Yes, matrix-synapse is affected in releases prior to 1.62.0rc1. Upgrade your dependency to 1.62.0rc1 or later.
What is the CVSS score of CVE-2022-31152?
CVE-2022-31152 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-31152?
CVE-2022-31152 is classified under CWE-703: Improper Check or Handling of Exceptional Conditions (The product does not properly anticipate or handle exceptional conditions that rarely occur during normal operation of the product.).
How can I check PyPI dependencies for CVE-2022-31152?
Run the dependency tree command: 'pip show matrix-synapse'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jhjh-776m-4765",
  "modified" : "2024-09-30T20:26:48Z",
  "published" : "2022-08-31T21:25:37Z",
  "aliases" : [ "CVE-2022-31152" ],
  "summary" : "Denial of service due to incorrect application of event authorization rules",
  "details" : "### Impact\n\nThe Matrix specification specifies a list of [event authorization rules](https://spec.matrix.org/v1.3/rooms/v10/#authorization-rules) which must be checked when determining if an event should be accepted into a room.\n\nIn versions of Synapse up to and including v1.61, some of these rules are not correctly applied. An attacker could craft events which would be accepted by Synapse but not a spec-conformant server, potentially causing divergence in the room state between servers.\n\n### Patches\n\nAdministrators of homeservers with federation enabled are advised to upgrade to v1.62.0 or higher.\n\n### Workarounds\n\n * Federation can be disabled by setting [`federation_domain_whitelist`](https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#federation_domain_whitelist) to an empty list (`[]`).\n\n### References\n\n * https://github.com/matrix-org/synapse/pull/13087\n * https://github.com/matrix-org/synapse/pull/13088\n\n### For more information\n\nIf you have any questions or comments about this advisory, e-mail us at [security@matrix.org](mailto:security@matrix.org).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "matrix-synapse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.62.0rc1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/security/advisories/GHSA-jhjh-776m-4765"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31152"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/pull/13087"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/pull/13088"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/commit/d4b1c0d800eaa83c4d56a9cf17881ad362b9194b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/commit/e16ea87d0f8c4c30cad36f85488eb1f647e640b0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/matrix-org/synapse"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matrix-org/synapse/releases/tag/v1.62.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/matrix-synapse/PYSEC-2022-262.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-703", "CWE-755" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-31T21:25:37Z",
    "nvd_published_at" : "2022-09-02T20:15:00Z"
  }
}