E2EE disabling plugin for Synapse

Overview

E2EE disabling plugin for Synapse

This Pluggable Module disables end-to-end encryption in a self-hosted Synapse servers. It works by stripping out requests for encryption from newly created rooms, patching power levels to prevent users from enabling encryption and additionally filtering out events for enabling E2EE on already existing rooms if a user or a room belongs to a configured list of servers.

This logic will work also on federated servers as long as they verify and enforce power levels.

Possible use-cases:

  • A legal requirement to provide auditable chat logs
  • Simplify deployments and operation for private homeservers where users don't care about E2EE and want to avoid issues with device verification, server-backed-up-keys etc.

Once this feature is implemented on Synapse side (https://github.com/matrix-org/synapse/issues/4401) this plugin will become obsolete.

Example config:

Plugin will strip away encryption from newly created rooms. In addition the plugin will filter out events for enabling encryption on room based on the server:

  • deny_encryption_for_users_of: if the event sender is on the server in the list (i.e. @user:example.org)
  • deny_encryption_for_rooms_of: if the room is on the server in the list (i.e. !room:example.org)

In your homeserver.yaml:

modules:
 - module: "matrix_e2ee_filter.EncryptedRoomFilter"
   config:
     deny_encryption_for_users_of: ['example.org']
     deny_encryption_for_rooms_of: ['example.org']

You may also want to add the following to your logging config to debug the plugin:

loggers:
    matrix_e2ee_filter:
        level: INFO

Caveats

This is not bullet-proof, a federated server that doesn't respect power levels may still allow users to enable encryption which will allow 3p users on other servers belonging to federation to freely use e2ee. This will create a divergence in room state and users on the server where this plugin is enabled won't be able to read encrypted messages - from their point of view the room will still be unencrypted.

Comments
  • Patch power levels on room creation

    Patch power levels on room creation

    Fixes https://github.com/digitalentity/matrix_encryption_disabler/issues/3

    This now works similar to https://github.com/fhirfactory/pegacorn-communicate-roomserver/pull/7, but still keeps encryption from being enabled from the start during room creation and filters the encryption events just to be safe.

    If federated servers and clients respect permissions room encryption should never be enabled even if the room is federated.

    @spantaleev you might want to test this change and make sure it works with your ansible playbooks (no reason why it shouldn't though).

    opened by digitalentity 4
  • Patch the 'm.room.power_levels' event if present instead of completely overwriting it

    Patch the 'm.room.power_levels' event if present instead of completely overwriting it

    Addresses some of the #5:

    • Adds a configuration setting patch_power_levels (default disabled)
    • Fixes the docs mentioning the option, how it works and why it may be dangerous
    • Patch the event instead of owerwriting it if already present
    opened by digitalentity 2
  • Fix documentation to use room id, not room address

    Fix documentation to use room id, not room address

    Looking at the filtering source code, checking is done against the room id (e.g. !room:example.org), not against the address of the room (#room:example.org). It works for rooms without address aliases.

    opened by spantaleev 1
  • New Synapse Module API support

    New Synapse Module API support

    Can this module be ported to the new Synapse Module API: https://matrix-org.github.io/synapse/v1.52/modules/index.html

    People will then be able to register it under modules in homeserver.yaml, and not under third_party_event_rules.

    I'd like to add support for this to matrix-docker-ansible-deploy and it'd be much easier if we can just inject it into the modules list, as opposed to defining third_party_event_rules which only seems to support just one filtering module.

    opened by spantaleev 1
  • Federated admin can still partly enable encryption

    Federated admin can still partly enable encryption

    Scenario:

    • Server 1: cleartext.info with this plugin installed and configured. Room !whatever:cleartext.info is created by @user1:cleartext.info
    • Server 2: paranoid.org without this plugin. User @user2:paranoid.org is participating in the room and is made admin. This can happen automatically if a room is a DM.

    User @user2:paranoid.org sets m.room.encryption without any restriction.

    Server cleartext.info will reject the m.room.encryption event during federation sync.

    Room is in inconsistent state. Users of the server cleartext.info are unaware that the room is now encrypted and can't sync the keys and read the encrypted messages.

    This can be worked around by patching on_room_creation further and modifying m.room.power_levels to make the power level for m.room.encryption event higher than admin (i.e. 101), but I'm not sure if that's possible during room creation - we may have to craft the entire m.room.power_levels event including the room membership.

    bug 
    opened by digitalentity 0
  • Sorry, a noob here, but how can I install this?

    Sorry, a noob here, but how can I install this?

    First than anything thank you for your work, I have a lot of time searching for something like this.

    I already have my matrix-synapse server up and running, I want to install this module but documentation about pluggable modules is limited or I don't understand yet. Inicially, how can I install the .py file before I can edit the homeserver.yaml? I tried everything but cannot install (I'm really new with python packages, sorry) multiple errors with pip like "cannot import module_api from synapse" and others. Please explain like I'm five, your work could save many lives in my organization.

    Thanks.

    Edit: I already installed the python plugin. but now I can't make it work in the yaml file.

    This is how it looks but it give me errors everytime

    imagen

    imagen

    opened by dfalfan 1
  • Change to a Python-compatible package, create build/setup scripts

    Change to a Python-compatible package, create build/setup scripts

    Fixes https://github.com/digitalentity/matrix_encryption_disabler/issues/7

    This module quickly grew from a pet personal enhancement for Synapse into a bigger thing which has some users. Making it a proper Python module became important at this point.

    opened by digitalentity 0
  • Improve room power level handling

    Improve room power level handling

    Does Synapse not validate these power level values? Is 150 a valid value? The m.room.power_levels description in the Matrix 1.2 spec does not seem to explicitly state that you can't use a value higher than 100.

    In practice, it seems like you've tested it and Synapse and the clients you've tested don't break, at least not yet.

    Still, it seems a little dangerous to use such values. Any homeserver that gets involved with this room over federation may encounter trouble. Even Synapse itself may reject this unusual value if it encounters it over federation (not tested, but it's a reasonable suspicion).


    So I think that this feature is a little dangerous to have, especially when enabled by default.

    It may make sense to:

    • try and clear up what the spec really says
      • [ ] can one go higher than 100?
      • [ ] should the next spec release make that explicit, so that other homeserver and client developers will be made aware of it?
    • test if such rooms can federate:
      • [x] most importantly with Synapse
      • [ ] Dendrite
      • [ ] Conduit
    • test other clients:
      • [x] I assume that at least Element (on which platform?) doesn't break
      • [x] and you've probably tested Fluffychat yourself
      • [ ] should some other clients be tested?
    • consider whether this should be "on by default and always". It creates a non-standard room that has potential to break and that cannot be fixed (I assume you can't bring m.room.encryption down to 100 or lower, once you've set it to a value than your own power level)
      • [x] a configuration setting may make sense
      • [x] disabling it by default may make sense
      • [x] consider mentioning in the docs (or configuration setting information, if a configuration setting is introduced) that power levels may be replaced with a borked up non-standard risky value
      • [x] .. and that all rooms created while matrix_encyption_disabler is active are forever prevented from becoming encrypted

    Originally posted by @spantaleev in https://github.com/digitalentity/matrix_encryption_disabler/issues/4#issuecomment-1037894963

    opened by digitalentity 3
Owner
Konstantin Sharlaimov
Konstantin Sharlaimov
Command line tool for monitoring changes of File entities scoped in a Synapse File View

Synapse Monitoring Provides tools for monitoring and keeping track of File entity changes in Synapse with the use of File Views. Learn more about File

Sage Bionetworks 3 May 28, 2022
A Python wrapper for Matrix Synapse admin API

Synapse-admin-api-python A Python wrapper for Matrix Synapse admin API. Versioning This library now supports up to Synapse 1.45.0, any Admin API intro

Knugi 9 Sep 28, 2022
Programmatic interface to Synapse services for Python

A Python client for Sage Bionetworks' Synapse, a collaborative, open-source research platform that allows teams to share data, track analyses, and collaborate

Sage Bionetworks 54 Dec 23, 2022
Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.

Xadmin Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap. Liv

差沙 4.7k Dec 31, 2022
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 1k Dec 16, 2022
A Linux webcam plugin for BGMv2 as used in our demos.

The goal of this repository is to supplement the main Real-Time High Resolution Background Matting repo with a working demo of a videoconferencing plu

Andrey Ryabtsev 144 Dec 27, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Simple JWT 3.3k Jan 1, 2023
A Django plugin for pytest.

Welcome to pytest-django! pytest-django allows you to test your Django project/applications with the pytest testing tool. Quick start / tutorial Chang

pytest-dev 1.1k Dec 31, 2022
A command-line tool and Python library and Pytest plugin for automated testing of RESTful APIs, with a simple, concise and flexible YAML-based syntax

1.0 Release See here for details about breaking changes with the upcoming 1.0 release: https://github.com/taverntesting/tavern/issues/495 Easier API t

null 909 Dec 15, 2022
Comprehensive Markdown plugin built for Django

Django MarkdownX Django MarkdownX is a comprehensive Markdown plugin built for Django, the renowned high-level Python web framework, with flexibility,

neutronX 740 Jan 8, 2023
A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

flake8-bugbear A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycode

Python Code Quality Authority 869 Dec 30, 2022
Pylint plugin for improving code analysis for when using Django

pylint-django About pylint-django is a Pylint plugin for improving code analysis when analysing code using Django. It is also used by the Prospector t

Python Code Quality Authority 544 Jan 6, 2023
❄️ A flake8 plugin to help you write better list/set/dict comprehensions.

flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions. Requirements Python 3.6 to 3.9 supported. Installation

Adam Johnson 398 Dec 23, 2022
Flake8 plugin that checks import order against various Python Style Guides

flake8-import-order A flake8 and Pylama plugin that checks the ordering of your imports. It does not check anything else about the imports. Merely tha

Python Code Quality Authority 270 Nov 24, 2022
flake8 plugin that integrates isort

Flake8 meet isort Use isort to check if the imports on your python files are sorted the way you expect. Add an .isort.cfg to define how you want your

Gil Forcada Codinachs 139 Nov 8, 2022
Flake8 plugin to find commented out or dead code

flake8-eradicate flake8 plugin to find commented out (or so called "dead") code. This is quite important for the project in a long run. Based on eradi

wemake.services 277 Dec 27, 2022
A Pylint plugin to analyze Flask applications.

pylint-flask About pylint-flask is Pylint plugin for improving code analysis when editing code using Flask. Inspired by pylint-django. Problems pylint

Joe Schafer 62 Sep 18, 2022
flake8 plugin to run black for checking Python coding style

flake8-black Introduction This is an MIT licensed flake8 plugin for validating Python code style with the command line code formatting tool black. It

Peter Cock 146 Dec 15, 2022
A plugin for flake8 integrating Mypy.

flake8-mypy NOTE: THIS PROJECT IS DEAD It was created in early 2017 when Mypy performance was often insufficient for in-editor linting. The Flake8 plu

Łukasz Langa 103 Jun 23, 2022