Locking down Matrix registration: tokens, CAPTCHA and invite-only sign-up

Matrix registration decides who can create an account on your homeserver. This page compares closed registration, registration tokens, CAPTCHA and SSO-only sign-up, and shows the MAS equivalents when the Synapse token API is off.

On this page

Who can create accounts on your Matrix server, and how to control it

Restricting registration is the first control to set on a self-hosted Synapse homeserver, because open sign-up lets anyone create accounts that can be used for spam, room abuse and credential stuffing against your users. In Synapse, the choice comes down to four options: keep registration closed, allow sign-up with a registration token, add a CAPTCHA challenge to the public form, or make SSO the only way in. Each one addresses a different risk. Closed registration with accounts created by administrators fits a small internal server with a known user list. Registration tokens fit a server where new people need a one-off invitation, since the uses_allowed and expiry_time fields limit how often and how long a token works. A CAPTCHA reduces automated sign-ups from bots but does not stop a person who is willing to solve the challenge, so it works best alongside other limits.

The token approach has an admin-side dependency to plan for. The token admin API is disabled when MAS integration is enabled, so a server that has moved account management to Matrix Authentication Service must use the MAS equivalents for invitations and sign-up rules instead. Check which service owns registration before you write any token process, and confirm the current MAS options in the Matrix Authentication Service documentation. Protect the registration_shared_secret in your Synapse configuration as a privileged credential, because anyone who holds it can create accounts regardless of your other settings. Store it in a secrets manager, restrict who can read the configuration file, and rotate it when staff with access change.

Decide the sign-up model before users arrive, and document it for your security reviewers. For a workforce server, SSO-only sign-up through your identity provider usually gives the clearest audit trail, because account creation and removal follow your existing joiner and leaver process. For a partner or community server, tokens with short expiry and a use limit give you a traceable invitation record. Test each path after changes: attempt registration as an anonymous user, with an expired token and with a token that has reached its use limit, and confirm each attempt fails. Pair these settings with Synapse's registration token documentation and your rate limits, so that any remaining public path is also throttled.

Registration options in Synapse and MAS and when each fits

This table compares the main ways to control who can create an account on a self-hosted Matrix server, from closed registration to SSO-only sign-up. Read each row for the typical fit, the admin work it creates, and the trade-off you accept. The main takeaway is that the token admin API is unavailable once MAS integration is on, so plan your registration flow before you enable it.

OptionTypical fitAdmin effortMain trade-off
Closed registrationStaff-only servers where an admin creates every accountLow day to day, high per new user; each account is created by handSimple and safe, but every new person waits on an admin
Registration tokens (Synapse)Small groups or partner orgs that need controlled self-sign-upModerate; create tokens with uses_allowed and expiry_time via the token admin APITokens can leak or be shared, so limit uses and expiry
Registration tokens (MAS)Deployments with MAS integration enabled, where the Synapse token API is disabledModerate; token handling moves to MAS administration, which you must confirm for your versionChanges the workflow and tooling, so test token issuance before rollout
CAPTCHAPublic-facing servers that see automated sign-up attemptsModerate; configure a CAPTCHA provider and keys, then test the sign-up pageBlocks bots but adds friction and does not stop a determined person with an approved token or open sign-up
SSO-only sign-upOrganizations that already run an identity provider such as Keycloak, Entra ID or AuthentikHigher upfront; connect the upstream provider and map claims, then disable local password sign-upCentral identity and offboarding, but depends on the identity provider being available
Open registrationRarely appropriate for an organization-controlled serverLow to set up, high to monitor for abuseMaximum convenience with the largest abuse and spam exposure
Protecting the shared secretAny Synapse server where the registration shared secret is enabledLow; keep the secret in a secrets store and restrict who can read the configAnyone holding the secret can create accounts, so treat it as an admin credential

Choosing a registration model by organization type

A single-company server usually has one owner, a corporate identity provider and a known list of staff. The simplest model is closed registration with no public sign-up path at all, so every account comes from the identity provider. With Matrix Authentication Service (MAS) in front, users sign in through upstream OpenID Connect providers such as Keycloak, Microsoft Entra ID or Authentik, and account creation follows the directory rather than a form. Registration tokens are then rarely needed, and CAPTCHA has little to protect.

  • Close public sign-up: Keep self-service registration disabled so accounts exist only where your directory or admin process creates them.
  • Use SSO as the only login: Configure one upstream provider in MAS and remove local password sign-in once staff are migrated.
  • Restrict federation: Set a federation_domain_whitelist limited to partner domains, or leave federation off if the company does not talk to other servers.
  • Keep an admin path: Retain a break-glass local admin account, stored in your secrets manager, for when the identity provider is unavailable.
  • Run offboarding: Tie account deactivation to HR or directory removal so departed staff lose access the same day.

Confirm with your identity provider team how group membership maps to Matrix access, and test a deprovisioning case before go-live.",

How to turn off open sign-up and issue registration tokens

This sequence moves a Synapse homeserver from open sign-up to token-gated registration, then proves that an unauthenticated attempt is refused. Each step ends with a check you can repeat after future configuration changes.

  1. Record the current registration state

    Before changing anything, confirm how sign-up works today. Open the homeserver configuration file (homeserver.yaml) and note the values of enable_registration, enable_registration_without_verification, and any registration_requires_token setting. Also check whether a Matrix Authentication Service (MAS) instance sits in front of Synapse, because that changes where sign-up is controlled. Capture a baseline by attempting an anonymous registration from a test client on a separate network. Done means you have a written record of the starting state and a failed or successful baseline attempt to compare against later.

  2. Disable open registration in configuration

    The homeserver operator edits homeserver.yaml to set enable_registration to false, which stops anyone from creating an account without an invitation or token. If you plan to use tokens, keep the registration path available for token holders only by enabling the token requirement in the same configuration change. Confirm the exact key names and their behavior against the Synapse configuration manual for your release, since keys can change between versions. Restart Synapse so the change takes effect. Done means the process starts cleanly and the configuration file validates without errors in the logs.

  3. Enable registration tokens or MAS sign-up

    Choose the sign-up path that matches your architecture. On a Synapse-only deployment, enable token-gated registration and create the first token through the admin API using the registration tokens endpoint. If MAS handles authentication, the Synapse token API is disabled when MAS integration is enabled, so token and invitation controls move to MAS settings and its admin tooling. Confirm the current MAS options in its documentation before relying on them. Done means the chosen path is active and the other path is clearly off.

  4. Create a limited-use, expiring token

    Using an admin account, create a registration token through the Synapse admin API. Set uses_allowed to a small positive integer so the token can register only that many accounts, and set expiry_time so it stops working on a fixed date. Leaving uses_allowed null makes the token unlimited, and setting it to 0 disables the token, so verify the value you sent. Record the token's name, its limits, and its owner in your access log. Done means a GET request on the token list shows the token with the expected uses_allowed and expiry_time values.

  5. Verify that a token registers exactly one account

    Use a test client on a separate network to register with the token. Confirm that the account is created and that the token's remaining uses drop by one when you query the token again. Then attempt a second registration with the same token after you have used up its allowed uses, and confirm that it is rejected. Done means the token enforces its use count and the rejected attempt returns an error rather than an account.

  6. Confirm unauthenticated sign-up fails

    Repeat the baseline attempt from Step 1 with no token and no invitation, using the same test client and network. The request should be refused with an error stating that registration is disabled or that a token is required. Check the Synapse logs to confirm the attempt was recorded and that no user row was created in the database. Repeat the check against the public client address if your reverse proxy exposes the registration endpoint. Done means every anonymous path returns a refusal and the logs show the refusal.

  7. Document the token process and revoke unused tokens

    Write down who may issue tokens, how limits and expiry are chosen, where tokens are recorded, and how to revoke a token by setting its uses to zero or deleting it through the admin API. Schedule a review of open tokens against your onboarding needs. Store the configuration file under version control so the registration settings can be audited later. Done means a named owner can state the process, and an open token list has been reviewed against the current onboarding roster.

How a sign-up request passes through registration controls

The diagram starts at a sign-up request arriving from the public internet at the reverse proxy in front of the homeserver. Synapse first checks whether registration is enabled, then whether a registration token is required and valid, and whether CAPTCHA is configured. When MAS handles authentication, the request is redirected to the upstream identity provider instead, and Synapse only receives the result. Check each branch against your own configuration, since the decision order is what determines which control actually stops an account.

Sign-up decision path with the trust boundary at the reverse proxy.

Protecting the registration shared secret

The registration shared secret is the value Synapse uses to authenticate administrative account creation, through the shared-secret registration endpoint and the command-line helper that ships with Synapse. Anyone who holds it can create accounts with administrator rights, and that power applies whatever your public registration settings say. Closed registration, tokens and CAPTCHA therefore govern self-service sign-up only, and the shared secret sits above them in your control model. Keep the value out of homeserver.yaml, which is often copied into tickets, backups and configuration repositories. Synapse documents a file-based option (registration_shared_secret_path) so the value can live in a restricted file or secret mount. Confirm the current key name, file ownership and permission requirements in the Synapse configuration manual before you change anything.

Limit the secret to a small, named group of platform administrators, and issue it through your secrets manager so access is logged and revocable. Keep it out of chat channels, wiki pages and shared runbooks. Any automation that creates accounts should be reviewed for whether it truly needs this secret or can use a narrower method. The risk of a leak is credential compromise, not just sign-up abuse: a person with the value can mint administrators who can read rooms, change settings and act as trusted users. Do not treat a leak as harmless because public registration is closed. Treat it as an incident, rotate the value, and review which admin accounts were created or changed during the exposure window. Ask your Synapse support contact or review the documentation to confirm how long a leaked value remains usable after rotation.

Rotate the secret on a schedule you can defend, and always after staff changes or any suspected exposure. The usual sequence is to generate a new value in the secret store, update the configuration or secret file, restart Synapse, and then confirm the old value is rejected. Check scripts, CI jobs and deployment templates for copies of the old value, since these are the most common leftovers. Record who was notified and when. If MAS has taken over account management on your server, confirm in the Synapse and MAS documentation whether the shared secret is still needed at all, because removing it may be a simpler control than rotating it. Verify the restart behavior and any effect on running sessions with the upstream documentation before you schedule the change.

Security risks in registration settings to review

Registration is the front door of a self-hosted Matrix server, and several settings decide who can create an account and how long that permission lasts. The cards below cover the risks we see most often when open sign-up, tokens, admin endpoints and SSO are configured separately from each other. Review them together, because a control in one place often fails when another setting is left open.

Open sign-up invites credential stuffing

If anyone on the internet can create an account, attackers can script registrations and test leaked username and password pairs against your login endpoints. Each new account also becomes a spam or abuse source on your federated server. Confirm that registration is closed unless you have decided otherwise, and check whether your login and registration rate limits are set in the Synapse configuration.

Configuration manual

Unlimited tokens leak to strangers

A registration token with uses_allowed set to null can be used by anyone who obtains it, with no ceiling on accounts created. Tokens copied into a shared wiki, a ticket or a chat channel tend to outlive the team that issued them. Ask who holds each active token, and set a finite use count for every token you issue.

Long-lived tokens stay valid

A token without an expiry_time remains usable until someone revokes it, which may never happen. Staff changes, contractor offboarding and forwarded invitations all leave valid credentials behind. Set an expiry on every token, and review the list of active tokens on a fixed schedule that your administrators agree on.

Exposed admin endpoints issue tokens

The registration token admin API can create and change tokens, so a reachable admin path lets an outsider mint their own invitation. Keep /_synapse/admin on a private network or behind an authenticated reverse proxy rule, and confirm that the public listener does not route admin paths. Test this from outside your network, not only from inside it.

SSO-only setups still allow local accounts

Enabling single sign-on does not by itself turn off local password registration. A server that keeps password-based sign-up open can accept accounts that bypass your identity provider's controls, such as MFA and offboarding. Confirm which registration path each account uses, and decide whether local passwords should remain at all.

Questions buyers ask about registration lockdown

How much effort does locking down Matrix registration take?

Most of the effort is decision work and testing, not configuration. Closing open registration, choosing between registration tokens, CAPTCHA and SSO-only sign-up, and confirming the MAS equivalents each need a deliberate choice, and each choice affects onboarding, bots and bridges. The configuration itself is small by comparison. Cost follows the number of deployment types you run (single Synapse, Synapse with MAS, or an ESS installation), how many user populations need different paths, and how much testing is needed before you change a live server. Ask any partner for a written scope that lists each registration path and the test cases for it.

What does the work need from our team?

Your team needs to supply the decisions and the access. Expect to name who may create accounts, how new users prove they belong, and which service accounts (bridges, bots, automation) must keep working. You will also need administrative access to the Synapse configuration, the homeserver host, and, if you use it, the Matrix Authentication Service and your identity provider. Someone from identity or IT operations should review changes to SSO and invitation flows. Without these inputs, any engagement stalls while questions are answered, so agree on the owners and the approval path before the scope is signed.

Can our own team lock down registration without outside help?

Yes, if you have people who can read the Synapse configuration manual and test changes on a staging server. The settings involved are documented, and the registration token admin API is part of Synapse. The risks are in the details: a token that never expires, a disabled registration path that breaks a bridge, or an admin API that is unavailable once MAS integration is enabled. Teams that do this in-house usually test each sign-up path from an outside network and keep a rollback plan. Outside help makes sense when you need that testing done on a fixed schedule or when several servers must match.

How long does validation take in general terms?

Validation depends on how many sign-up paths you keep and how much of the flow runs through your identity provider. A closed server with one approved path needs a short test cycle. A server with tokens, CAPTCHA and SSO sign-up needs each path tested for success, failure and abuse, plus a check that existing accounts still sign in. No duration figure has been established for this work, so ask any provider to state the test steps and the review points in the written plan, and confirm how long your change window is before work starts.

What recurring work do registration tokens create?

Tokens are not one-time setup. Each token has a uses_allowed count (null for unlimited, 0 to disable) and an expiry_time, so someone must decide how long tokens live, who may issue them, and when to retire them. Unlimited tokens that are never reviewed are the common failure. Plan a recurring review of active tokens and their use counts, and make sure the person who issues tokens can also revoke them. If your deployment uses the Matrix Authentication Service, token management moves to MAS, so the review process must follow the tool that actually controls sign-up.

Which costs recur after registration is locked down?

Recurring costs come from reviewing sign-up logs, rotating shared secrets when staff change, updating CAPTCHA or identity provider settings after upgrades, and retesting after each Synapse release. Upgrade notes change between versions, so each upgrade may affect registration behavior. Ask whether a quote includes a retest after upgrades, how account requests are handled, and who approves changes to sign-up rules. Ongoing support can be set up as a retainer, which covers recurring checks without restarting the scope each time.

What should we protect first: the shared secret or the sign-up rules?

Protect both, but the shared secret carries the higher impact. The registration shared secret lets anyone with it create accounts, including administrators, so it should live in a secrets store with restricted access and be rotated when people leave the team. Sign-up rules matter next, because a permissive token or CAPTCHA setting lets outsiders create accounts without any secret. Check that the shared secret is absent from configuration files in version control, and that only the people who need it can read the homeserver configuration.

Keeping token and invite processes working after launch

Registration controls drift after launch unless someone owns them. Name one accountable owner for registration tokens, usually the Matrix administrator or the team that runs identity, and write down who may request a new token, who approves it, and where it is recorded. If tokens are issued through the Synapse admin API, the owner should also know who holds the shared secret and admin access tokens, since those credentials can create tokens and accounts without any approval step. Review the token list on a fixed schedule. Each token's uses_allowed and expiry_time fields show whether it is still unlimited, already exhausted, or set to expire, and tokens with uses_allowed set to unlimited and no expiry should be treated as standing exceptions that need a stated reason. Confirm the exact fields and the list and revoke calls against the registration tokens admin API for the version you run.

Keep an audit trail for every registration change. Record each token creation, change and deletion, each config edit that toggles enable_registration, registration_requires_token, CAPTCHA or SSO-only sign-up, and each account created through a token, then review those records on a regular cadence against the approvals you expect. Where MAS handles registration, confirm which settings and actions it logs and where those logs go before relying on them, because the Synapse token API is disabled when MAS integration is on. Log retention should match your internal policy, and the review should compare what happened with what was approved, not only look for obvious abuse.

Plan every upgrade as a registration test. Read the upgrade notes for each Synapse release you cross, since changes to registration, token handling or the admin API can alter behavior, and confirm that existing tokens, CAPTCHA settings and SSO mappings still work on a staging copy before production. The upgrade notes also warn that rolling back can be difficult because of database schema changes, so take a database backup before the upgrade and do not assume a downgrade will restore older token behavior. After each upgrade, create a test token, register one test account, and confirm that closed sign-up still refuses anonymous attempts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.