Extending Synapse with modules: what they change and when you need them
A team running a self-hosted Synapse homeserver often reaches a point where it needs one extra rule, such as filtering spam, checking events against company policy, routing presence, or enforcing a password check. Forking the server to add that rule creates a code base you must merge and retest on every upgrade. Synapse modules are the supported extension point for this. A module is a Python class that Synapse loads at startup, and it can register behavior through four interfaces: the spam checker, third-party event rules, the presence router and the password auth provider. Before writing or installing anything, the first decision is whether a stock Synapse setting or an existing service already covers the need. Registration controls, rate limits, the room directory settings and identity provider integration handle many policy goals without any custom code.
When a module is justified, the configuration is where the risk shows up. Modules are listed under the modules section of the Synapse config, and each entry names a module class path and carries its own config block. When several modules register the same callback or HTTP path, the module listed earlier wins, so the order in the file changes behavior and should be reviewed as carefully as the code. Synapse refuses to start if modules register conflicting password auth checkers, which is a useful safety check, but it does not catch a spam checker that silently overrides another. Your change process should record the intended order, the owner of each module and the test that proves the outcome. Check the exact interface names and config keys in the Synapse modules documentation for the version you run, because they are version-specific.
Every third-party module runs someone else's code inside your homeserver, with access to user events, passwords or presence data depending on the interface. The Synapse documentation warns admins to verify where modules come from, so treat module selection like a dependency review. Ask the author or vendor for the source repository, license, maintenance history and the Synapse versions it is tested against. Confirm which data each interface can read, and whether the module makes outbound network calls. Test it on a staging homeserver with a copy of your configuration before production. Plan a recurring review for each module at every Synapse upgrade, since an interface change can break a module without a visible error until users hit the affected path.
Which Synapse module interfaces solve which problem
Synapse exposes four module interfaces, and each one changes a different part of the server's behavior. Choosing the right interface starts with the operational question you need answered, because each interface gives a module a different level of control over messages, presence, or logins. Read each card for the question it answers and the risk it adds before you write a single line of module configuration.
Spam checker interface
Use the spam checker interface when you need a module to inspect incoming events or user registrations and decide whether they look like spam. It answers the question of how to filter unwanted content without writing custom server code. The risk is false positives: a misfiring checker can silently block legitimate messages or invites, so test it against real traffic patterns in a staging homeserver first. Confirm the exact callbacks for your release in the modules documentation before you wire it in.
Synapse modules docsThird-party event rules interface
Third-party rules let a module examine and act on events as they are created or received, which suits policies such as blocking certain room actions or enforcing naming conventions. It answers the question of how to apply an organization policy to every event on the server. The main risk is performance and ordering: a rule that runs on every event adds latency to all rooms, and an earlier module in the config can change what later modules see. Confirm the event callbacks against your release.
Presence router interface
A presence router decides which presence states a homeserver sends or accepts, and it is the interface to reach for when you need to control who sees online status. It answers the question of how to limit presence exposure for privacy or compliance reasons. The risk is that presence feeds into client behavior and into federation, so an overly restrictive router can make the server appear inconsistent to users on other homeservers. Test with users on a remote server before rolling out.
Password auth provider interface
A password auth provider lets a module check credentials against an external store, such as a directory, when the homeserver handles login itself. It answers the question of how to authenticate users against a system you already run. The critical risk is authentication failure: Synapse refuses to start if modules register conflicting password auth checkers, and a flawed checker can lock out staff or accept invalid passwords. Compare this with an OIDC or SAML login path before choosing it, and confirm the hook names for your release.
How the modules section and config block load a module
Synapse modules are declared under the modules section of homeserver.yaml. Each entry names a module class path and carries its own config block, which Synapse passes to the module when the homeserver starts. The class path tells Synapse which Python package to import, so the entry must match the installed package exactly. The config block is where the module's own settings live, such as lists of allowed domains, scoring thresholds or webhook endpoints. Keep each block under the module's own documentation, and confirm the expected keys against that module's release before you copy settings from another server.
Order matters. When several modules register the same callback or HTTP path, the module listed earlier takes precedence. Ordering is therefore a policy decision, not a formatting choice. Decide which module should see an event or request first, record that order in your change log, and review it whenever you add or remove a module. A spam checker placed above a moderation module, for example, can change which module ever sees a given event. The Synapse modules documentation describes the precedence rules, so check the current text for the version you run.
Synapse also refuses to start if modules register conflicting password auth checkers, so a bad combination fails loudly at startup rather than silently in production. Test every change to the modules section on a non-production server that uses the same Synapse version, database engine and identity setup. Confirm that the homeserver starts, that a test user can log in through each password path, and that the callbacks you expect fire. Keep the previous homeserver.yaml so you can restore it quickly, and plan the rollback path before the change window opens.
Module options and when each fits
This table compares the four module interfaces Synapse supports: spam checking, third-party event rules, presence routing and password authentication. Read each row to see what the interface changes, where it usually appears, and which ordering or conflict risk to check before enabling it. The main takeaway is that module order in the config decides which module wins, and password auth checkers can block startup if they conflict.
| Interface | What it changes | Typical use | Ordering or conflict risk | What to confirm |
|---|---|---|---|---|
| Spam checker | Inspects events and decisions on whether incoming or outgoing content is allowed | Filtering unsolicited or abusive messages and invites on a public or federated server | Earlier modules in the modules section take precedence when several register the same callback | Which callbacks the module registers, and whether its blocking rules match your moderation policy |
| Third-party rules | Applies custom checks to events and room state before they are accepted | Enforcing organization rules on room creation, events or membership changes | Order matters, since earlier modules win when callbacks overlap with later ones | Which event types it touches and how it behaves with encrypted rooms and bridges |
| Presence router | Decides which worker handles presence updates for users | Routing presence traffic in a worker-based deployment | Routing decisions must not conflict with other presence routing in the same config | Compatibility with your Synapse version and worker layout, and the author's support plan |
| Password auth provider | Adds a custom check for local password logins | Checking passwords against an external directory during a transition | Synapse refuses to start if modules register conflicting password auth checkers | Whether it replaces or supplements your SSO setup, and how it handles account lockout and failed attempts |
How a request passes through ordered modules
A client request or federation event enters Synapse and is offered to each configured module in the order listed under the modules section of the config. Earlier modules win when several register the same callback or HTTP path, so the order is a policy decision and not a cosmetic one. If a module refuses the event, it stops at that point and never reaches the core handler. The password login path is separate: when more than one module registers a password checker that conflicts with another, Synapse refuses to start, so check the startup log after every module change.
Modules are consulted in config order, and a conflicting password checker blocks startup.
Setting up a module in your Synapse config
This sequence takes a third-party or in-house Synapse module from the interface you need to a verified config entry running on a staging server, so you know its behavior before it touches production users.
Choose the interface your module needs
Decide which Synapse module interface solves the problem: spam checking, third-party event rules, presence routing or password authentication. Write down the callbacks or HTTP paths the module must register and the Synapse version you run, since the module must match it. Confirm with the module's maintainers which Synapse releases it supports. The step is done when you have a one-line requirement and a list of supported versions to check against your server.
Vet the module source before installing
Obtain the module only from a source your security team has reviewed. Read the source code, check the maintainer, the license, the recent commit history and any open issues, and confirm the release you plan to install matches what you reviewed. Pin the exact version and record a checksum. The Synapse documentation warns that a third-party module runs someone else's code on your server, so treat this review as a gate. The step is done when a named reviewer has approved the pinned version in writing.
Install the module in the Synapse environment
Install the approved, pinned module into the same Python environment that runs Synapse, whether that is a virtual environment, a package or a container image you build. Do not install it into the system Python used by other services. Confirm that the module imports cleanly from the Synapse interpreter, for example by running a plain import of its module path. The step is done when the import succeeds and the installed version matches the pinned release.
Add the class path and config under modules
Open the Synapse configuration file and add an entry under the modules section with the module's class path and its config block, following the module's own documentation for keys and types. Place the entry where you want it in the list, because earlier modules take precedence when several register the same callback or HTTP path. Note the position and the reason for it in your change record. The step is done when the file parses and the entry sits in the intended order.
Validate the config on a staging server
Copy the configuration and the module installation to a staging homeserver that mirrors production's Synapse version, database and reverse proxy settings. Run Synapse's config validation and start the process in the foreground. Watch the startup log for module load messages and errors. Synapse refuses to start if modules register conflicting password auth checkers, so a clean start is the first real check. The step is done when Synapse starts without configuration or module errors on staging.
Test behavior with dedicated test accounts
Create test accounts that exist only on staging and run the scenarios the module is meant to change: a message the spam checker should block, a room event the third-party rule should reject, or a login the password provider should accept or refuse. Include at least one case that should pass normally so you can see the module does not over-block. Record the expected and actual results. The step is done when every planned scenario behaves as documented and the results are saved.
Roll out to production and confirm
Apply the same pinned module and config to production during a planned change window, keeping a copy of the previous configuration so you can restore it. Start Synapse, check the logs for the module's load messages, and repeat a short set of the staging checks using test accounts that you then deactivate. Keep the rollback copy until you have confirmed normal operation. The step is done when production logs show the module loaded and the test scenarios match staging results.
How to vet third-party modules before they run on your server
The Synapse documentation warns that third-party modules run someone else's code on your homeserver, so vet every module as you would any code that handles your users' messages. Before a module enters the config, review its source repository, the identity and track record of its maintainers, its license and whether that license fits how your organization distributes and operates software, its declared dependencies, and its update history, including how quickly security issues were fixed in the past. Confirm which Synapse versions the module supports, since a module written against one interface can break after a Synapse upgrade. Ask whether an unmaintained module can be forked and carried by your own team if the upstream project stops.
Give extra attention to code that runs in the request path. Spam checkers, third-party event rules and password auth providers are called while events are being sent, accepted or authenticated, so a slow, crashing or permissive callback affects every user at once. Read each callback the module registers and note what data it receives, including message content, and whether it makes outbound network calls. Pin the module to a specific reviewed version in your build or deployment artifact rather than pulling the latest release at startup, and record the checksum or commit you reviewed so that a later change is visible in review. Test each upgrade on a staging homeserver with a copy of realistic traffic patterns, room sizes and federation activity, and watch for changes in latency and error rates before the production rollout.
Decide who can change the modules list in the homeserver config before the first module goes live. Treat that list as a privileged change: it should go through the same review and approval path as other security-relevant configuration, with the admin who makes the change separate from the person who approves it. Keep the modules in version control with the reviewed version recorded, and restrict write access to the configuration repository and the host. Confirm with your Synapse vendor or the module maintainer how the module handles errors, and plan a rollback path that removes the module entry and restarts the homeserver, because a module that refuses to start can take the whole server down. Document the review outcome so that auditors and your security team can see why each module was approved.
Security and operational risks of running module code
A Synapse module runs inside the homeserver process, so it sees the same messages, user records and login attempts that Synapse does. The risks below connect through that position: a module can read data it should not, change outcomes through its position in the config, block logins, break on upgrade, or change behavior without a record.
Unreviewed code with data access
A module loaded through the modules section runs inside the Synapse process with access to message content, user data and the same database access Synapse has. The Synapse docs warn that third-party modules run someone else's code on your server. Before enabling one, read the source at the exact version you will install, check who maintains it, and confirm which Synapse callbacks it registers. Pin the package to a reviewed version and rebuild it from a reviewed source rather than installing whatever the latest release contains.
Synapse modules docsOrdering conflicts that change moderation
Earlier modules win when several modules register the same callback or HTTP path. If a spam checker placed above a newer checker already rejects an event, the later checker never runs, and the outcome looks like normal moderation. Illustratively, a reordered list could let spam through with no error in the logs. Keep the modules list in a version-controlled file, record the order in the change request, and test a known spam message after every change to that list.
Password checks that lock out users
Synapse refuses to start if modules register conflicting password auth checkers, which protects against one conflict but not against a checker that rejects valid passwords. A password provider that fails to reach its backend can block every login on the server. Before rollout, test a login for a normal account, a service account and an admin account against a staging server, and confirm the fallback path with the module owner. Keep a local admin account reachable through a documented route for recovery.
Upgrade breakage from internal changes
Modules call Synapse interfaces that the project may change between releases. A module built for one version can fail to load or behave differently after an upgrade, and a failed upgrade is hard to roll back because of database schema changes. Read the upgrade notes for each release before updating, check that the module publishes a release for the target Synapse version, and run the upgrade in a staging environment that mirrors the production database. Ask the module owner how they track Synapse releases.
Synapse upgrade notesMissing audit trail for changes
A module can change how events are filtered, routed or authenticated without any entry in the Synapse admin audit records. If the module list and its configuration are edited directly on the server, nobody can later show who enabled a module, which version ran, or when a moderation rule changed. Store the config and the module version in Git, deploy through a pipeline that records the approver, and keep the deployed artifact hash. Confirm with your compliance team which of these records they need to keep.
Questions teams ask before adding Synapse modules
What drives the cost of adding a Synapse module?
The cost follows the number of callbacks the module registers, how much of your existing Synapse behavior it touches, and how much review the code needs before it runs on your server. A spam checker that only inspects events is a smaller job than a password auth provider, because the auth provider sits on the login path and must be tested against every sign-in method you support. Cost components are the engineering time to write or adapt the module, the review of third-party code, staging work, and the ongoing effort to keep the module working after upgrades. Ask any partner to split the quote into design, build, review, testing and handover so you can see which part is one-time and which recurs. No cost figure is given here because none was supplied for this topic.
Can our internal team add a Synapse module on its own?
Yes, if your team already runs Synapse and has a developer comfortable with Python and the module interfaces. The module system covers the spam checker, third-party rules, presence router and password auth provider interfaces, and each one has its own callbacks and failure modes. The harder part is judging third-party code, because the Synapse documentation warns that modules run someone else's code on your server. Teams without a Synapse developer or a security reviewer usually find the review step is where they need outside help. Confirm your skills against the modules documentation before committing.
What do we need to provide during a module engagement?
Plan to provide a staging homeserver that matches production closely enough to test the module, including the same Synapse version, database engine and identity provider settings. You will also need test accounts covering each login path, rooms and users that exercise the callbacks, and a named reviewer on your side who can approve the module source and its configuration. Without staging, changes to spam checking or authentication can lock users out or block legitimate messages. Ask the partner to list these inputs in the written scope so both sides know what is owed before work starts.
How long does a module review usually take?
The length depends on scope: the number of modules, how many callbacks each one registers, whether it touches authentication, and how much of the source you must audit. A single well-documented module that only reads events can be reviewed quickly, while several modules with overlapping callbacks need more time to check ordering and conflicts. Your ordering in the modules section of the config also matters, because earlier modules win when several register the same callback or HTTP path. Ask for a timeline tied to the agreed scope rather than a generic estimate.
Should we tune stock Synapse settings or an existing service first?
Tune stock Synapse settings and existing services first when they can meet the requirement, because a module adds code you must review, test and maintain. Many spam and access concerns can be handled through configuration, rate limits or an identity provider you already run. Only write or adopt a module when a documented setting cannot reach the behavior you need. Check each candidate against the Synapse configuration manual before deciding, and record why a module was chosen so reviewers can see the reasoning later.
How do Synapse upgrades affect our modules?
Each upgrade can change the module interfaces, the callbacks Synapse calls, and the Python and PostgreSQL versions required. The upgrade notes also warn that rolling back can be difficult because of database schema changes between releases, so test modules on staging against the target version before touching production. Keep the module pinned to a known source revision, record its config block, and repeat the test accounts after each upgrade. Ask the partner who will own that retest cycle and how it is priced, since it recurs for as long as the modules run.
How DeployOpen scopes module work on Synapse
DeployOpen plans and implements Synapse on infrastructure you control, so any module that runs inside the homeserver process runs on your own hosts, under your own change control. Module work is scoped as part of that deployment rather than as a separate add-on. The engagement starts with an inventory of the modules you already run or want to run, the callbacks each one registers, and the business reason for each. Each proposed module is reviewed for where its code comes from, who maintains it, which Synapse versions it targets, and whether it registers a password auth checker that could conflict with another module or with your SSO setup.
Testing happens on a staging homeserver built from the same configuration as production. DeployOpen tests each module's behavior against realistic message, invite and login traffic, checks the order of the modules entries in the config, and confirms that the startup behavior is as expected, including the refusal to start when password auth checkers conflict. Where a module changes how events, presence or logins are handled, the test plan records what users will notice and what the moderation or support team will need to answer. Findings are reported in writing with the fixes needed before production.
Deliverables are agreed in writing before work starts. A typical written scope lists the modules in scope, the staging and production environments, the configuration documentation for your compliance and security teams, the test cases and their results, and the acceptance criteria. Most engagements are fixed-scope, and timelines follow from that agreed scope. Ongoing support, module upgrades after each Synapse release and retesting when a module changes are available as a retainer. Ask any provider, including DeployOpen, to confirm in writing which module versions are covered and how upgrades are handled.

