Commit Graph
25958 Commits
Author SHA1 Message Date
catfromplan9andGitHub 0b086d1531 Fix thumbnailing MPO images (#20025)
Signed-off-by: cat <cat@plan9.rocks>
2026-08-11 13:52:49 +00:00
Olivier 'reivilibreandGitHub d80a4e69da Dust off make_full_schema and add CI using it to show schema diffs. (#20027)
It seems a lot of time in our trial tests goes towards setting up the
database. (The same is probably true of Complement too)

We haven't done a full schema for about 20 schema versions, so no
surprise!

As a result, I want to produce a full schema soon.

In this PR I dust off `make_full_schema.sh` (which seems to have broken
after some SQLite changes)
and add a CI workflow that runs it (producing a diff) when someone
changes the schema.

The CI workflow also adds a sticky comment showing the diff on the
schema, so you can better appreciate the final effect of a change.

---

**Dead changes:**

I wanted to make it possible to generate a versioned full schema without
the manual work,
but you can't run the background updates without essentially starting up
a homeserver,
at which point it might fail because you haven't run all the deltas yet.

There's no actual good way to do this, short of deleting the latest
deltas (+ tweaking code to not crash without them)
or rolling back in the git history.

Backed out those changes, but they're preserved on the PR if interesting.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-08-11 12:55:59 +01:00
dependabot[bot]andGitHub 3caf917165 Bump actions/setup-go from 6.5.0 to 7.0.0 (#20045)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 10:55:35 +00:00
dependabot[bot]andGitHub 940baa8c6b Bump actions/setup-python from 6.3.0 to 7.0.0 (#20044)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 10:55:11 +00:00
dependabot[bot]andGitHub 235a9e1aa5 Bump docker/login-action from 4.4.0 to 4.5.2 in the minor-and-patches group (#20088)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 10:49:01 +00:00
dependabot[bot]andGitHub 68bb5e220a Bump gitpython from 3.1.57 to 3.1.58 (#20079)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-11 10:42:32 +00:00
Eric EastwoodandGitHub 93f4ea43c7 Fix tests that use homeserver_to_use=GenericWorkerServer not being able to be run standalone (#20017)
*Spawning from
https://github.com/element-hq/synapse/pull/19057#discussion_r2427537811,*

Fix tests that use `homeserver_to_use=GenericWorkerServer` not being
able to be run standalone

Fix https://github.com/element-hq/synapse/issues/15671 (previously
https://github.com/matrix-org/synapse/issues/15671)

Before this change:

```shell
$ poetry run trial tests.storage.test_rollback_worker.WorkerSchemaTests.test_rolling_back
tests.storage.test_rollback_worker
  WorkerSchemaTests
    test_rolling_back ...                                               [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "synapse/tests/unittest.py", line 129, in new
    return code(orig, *args, **kwargs)
  File "synapse/tests/unittest.py", line 223, in setUp
    return orig()
  File "synapse/tests/unittest.py", line 398, in setUp
    self.hs = self.make_homeserver(self.reactor, self.clock)
  File "synapse/tests/storage/test_rollback_worker.py", line 54, in make_homeserver
    hs = self.setup_test_homeserver(homeserver_to_use=GenericWorkerServer)
  File "synapse/tests/unittest.py", line 669, in setup_test_homeserver
    hs = setup_test_homeserver(
  File "synapse/tests/server.py", line 1260, in setup_test_homeserver
    prepare_database(
  File "synapse/synapse/storage/prepare_database.py", line 167, in prepare_database
    raise UpgradeDatabaseException(EMPTY_DATABASE_ON_WORKER_ERROR)
synapse.storage.prepare_database.UpgradeDatabaseException: Uninitialised database: run the main synapse process to prepare the database schema before starting worker processes.

tests.storage.test_rollback_worker.WorkerSchemaTests.test_rolling_back
-------------------------------------------------------------------------------
Ran 1 tests in 0.034s

FAILED (errors=1)
```


### What was the problem before?

[`PREPPED_SQLITE_DB_CONN`](https://github.com/element-hq/synapse/blob/1a1af7b622f219ba0f2501709298caa230ad3912/tests/server.py#L1247-L1262)
is a process global and shared between all tests. Whichever test first
calls `setup_test_homeserver(...)` builds the template database for the
whole trial run.

`prepare_database(...)` has a built-in check to refuse upgrading the
database ["to avoid multiple workers doing it at
once."](https://github.com/element-hq/synapse/blob/1a1af7b622f219ba0f2501709298caa230ad3912/synapse/storage/prepare_database.py#L164-L167)
and throw `UpgradeDatabaseException`.

This means that if we happen to first run a test that uses a worker
(`homeserver_to_use=GenericWorkerServer`), `prepare_database(...)` will
just throw its `UpgradeDatabaseException`. And since
`PREPPED_SQLITE_DB_CONN` is assigned before `prepare_database(...)`, it
will never try to prepare again and the rest of the tests will fail.
2026-08-10 16:34:56 -05:00
Eric EastwoodandGitHub cf8ebebd03 Run with PYTHONUNBUFFERED=1 so we can always see log output (#20075)
We already have [`flush_buffers()` in
`start.py`](https://github.com/element-hq/synapse/blob/f4cf7ab29e3f3c2488425459294a87d1da636d69/docker/start.py#L24-L31)
for the happy explicit path.

Follow-up to https://github.com/element-hq/synapse/pull/18420

This is the same thing we run with in the Synapse Pro for small hosts
project, see https://github.com/element-hq/synapse-small-hosts/pull/42

The reason I'm making this change now is that I'm trying to make our
Synapse FOSS build similar to our 'Synapse Variants' build we use for
all of the Synapse Pro builds. The 'Synapse Variants' builds includes a
build for the `multi_synapse` shard and we have [`PYTHONUNBUFFERED=1` in
that
`Dockerfile`](https://github.com/element-hq/synapse-small-hosts/blob/b64bd32c3feabdf06664a36f36ae0dced541fc66/docker/Dockerfile#L192-L193)
which seems like a good measure to also have here.


### Dev notes


> #### programming languages where the default “print” statement buffers
> 
> Also, here are a few programming language where the default print
statement will buffer output when writing to a pipe, and some ways to
disable buffering if you want:
> 
> - Python (disable with `python -u`, or `PYTHONUNBUFFERED=1`, or
`sys.stdout.reconfigure(line_buffering=False)`, or `print(x,
flush=True)`)
> 
> _--
https://jvns.ca/blog/2024/11/29/why-pipes-get-stuck-buffering/#programming-languages-where-the-default-print-statement-buffers_
2026-08-10 10:22:04 -05:00
62a4bc4620 Fix quarantined_media stream not being replicated (#20085)
The registration of `QuarantinedMediaStream` in
`ReplicationCommandHandler._streams_to_replicate` was missed when the
stream was added, so an instance configured as the
quarantined_media_changes stream writer never sent RDATA/POSITION for it
unless it was the main process.

Also add the stream to the `instance_map` config validation.

Stream was introduced in
https://github.com/element-hq/synapse/pull/19558

Fixes https://github.com/element-hq/synapse/issues/20080

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-10 15:47:01 +01:00
81a42c42ad Abort transactions that sits idle for too long. (#20077)
Set `idle_in_transaction_session_timeout` on new postgres connections

Idle transactions can block maintenance tasks server-side like vacuums,
which can lead to bloat and performance issues.

We should never hit this timeout in normal operation, as Synapse should
always be actively using the connection when in a transaction and so it
should only ever be briefly idle. If we do hit this timeout, it's likely
that no progress is being made and so aborting the session is safe.

In certain cases we have seen connections leak, particularly when using
a connection pooler like pgcat, and this timeout will help with that.

---------

Co-authored-by: Eric Eastwood <erice@element.io>
2026-08-10 15:46:39 +01:00
Olivier 'reivilibreandGitHub 8aef536bbe Introduce an RdataSafeValue type and correct some minor type annotation mistakes. (#20071)
Introduce a `SafeRdataValue` type that represents what is safe to push
over the wire in RDATA commands.

Spawns from a mistake when working on
https://github.com/element-hq/synapse/pull/19556

Would have caught the issue that
https://github.com/element-hq/synapse/pull/19556/commits/9bcd110080849575ce11d9b50806423867b5c1b5
fixes.

At the same time, correct some mistaken type annotations that flared up
after this correction.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-08-10 14:34:42 +01:00
Eric EastwoodandGitHub 0654c312db Add upgrade notes to point out updated Debian package signing key (2026) (#20066)
Part of https://github.com/element-hq/synapse/issues/20038

Language based on the previous time we did this: https://github.com/element-hq/synapse/blob/3cb6c3484daa59c56bbc3d8df295e011c9f0d2cf/docs/upgrade.md?plain=1#L415-L431
2026-08-07 15:30:49 -05:00
Hugh Nimmo-SmithandGitHub f4cf7ab29e Clarify media upload limit callback triggers (#20018) 2026-08-07 17:44:06 +01:00
Erik JohnstonandGitHub e3d9b15cc6 Cleanup cancelled tasks as well (#20068)
Rather than just completed and failed tasks.
2026-08-06 18:11:32 +01:00
c5f02a9313 Introduce support for MSC4429: Profile Updates for Legacy Sync (#19556)
Implements support for [MSC4429: Profile Updates for Legacy
Sync](https://github.com/matrix-org/matrix-spec-proposals/pull/4429).

Paired with https://github.com/matrix-org/complement/pull/849 and
https://github.com/matrix-org/sytest/tree/anoa/msc4429

Tracking issue for removing unstable identifiers in Synapse:
https://github.com/element-hq/synapse/issues/19891
Further improvements tracked in:
https://github.com/element-hq/synapse/issues/19981

---------

Co-authored-by: Half-Shot <will@half-shot.uk>
Co-authored-by: Jason Robinson <jasonr@element.io>
Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
2026-08-06 15:35:07 +01:00
dependabot[bot]andGitHub 556154848c Bump gitpython from 3.1.54 to 3.1.57 (#20046)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:11:56 +00:00
dependabot[bot]andGitHub 701baedbea Bump actions/checkout from 7.0.0 to 7.0.1 in the minor-and-patches group (#20043)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:09:50 +00:00
dependabot[bot]andGitHub 98a0cae3c3 Bump the patches group with 6 updates (#20042)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:09:27 +00:00
Olivier 'reivilibreandGitHub 320265f09b Remove broken DROP statements for SQLite in make_full_schema script. (#20028)
Broken out of #20027 because I'd like to have it land first.

> It seems a lot of time in our trial tests goes towards setting up the
database. (The same is probably true of Complement too)
> 
> We haven't done a full schema for about 20 schema versions, so no
surprise!
> 
> As a result, I want to produce a full schema soon.

When running `make_full_schema.sh`, these drop statements now cause the
error:

```
Parse error near line 2: table event_search_content may not be dropped
Parse error near line 3: table event_search_segments may not be dropped
Parse error near line 4: table event_search_segdir may not be dropped
Parse error near line 5: table event_search_docsize may not be dropped
Parse error near line 6: table event_search_stat may not be dropped
Parse error near line 7: table user_directory_search_content may not be dropped
Parse error near line 8: table user_directory_search_segments may not be dropped
Parse error near line 9: table user_directory_search_segdir may not be dropped
Parse error near line 10: table user_directory_search_docsize may not be dropped
Parse error near line 11: table user_directory_search_stat may not be dropped
```

It seems SQLite has cracked down on code that edits the internal tables.

Because SQLite dumps the schema with `CREATE TABLE IF NOT EXISTS` for
these virtual tables, it's harmless to leave them in the schema dump.

---------

Signed-off-by: Olivier 'reivilibre' <oliverw@matrix.org>
2026-08-06 10:15:21 +01:00
Eric EastwoodandGitHub 3cb6c3484d Document how to capture a JSON snapshot of a Grafana dashboard (#20048)
To make it easy to share to people and aid in debugging when they run into
performance issues.

Unfortunately, the Grafana UI doesn't make the export or import steps
easy so it involves some manual Grafana API calls.

As first explored in
https://github.com/element-hq/synapse-rust-apps/pull/397
2026-08-05 11:11:30 -05:00
Eric Eastwood c9da03e576 Merge branch 'master' into develop 2026-08-04 14:12:18 -05:00
Eric Eastwood 7a3e98b6f7 1.158.0 v1.158.0 2026-08-04 12:53:51 -05:00
Eric EastwoodandEric Eastwood 5b29f8160e Drop support for Ubuntu 25.10 'Questing Quokka', add support for Ubuntu 26.04 'Resolute Raccoon' (#20039)
Fix https://github.com/element-hq/synapse/issues/20031

### Dev notes

 - https://endoflife.date/ubuntu
 - https://endoflife.date/debian
 - https://endoflife.date/python

Finding Python version on distros:

 - https://packages.debian.org/trixie/python3
 - https://packages.ubuntu.com/resolute/python3
2026-08-04 09:12:10 -05:00
Eric EastwoodandGitHub 2c8bf9a3ab Drop support for Ubuntu 25.10 'Questing Quokka', add support for Ubuntu 26.04 'Resolute Raccoon' (#20039)
Fix https://github.com/element-hq/synapse/issues/20031

### Dev notes

 - https://endoflife.date/ubuntu
 - https://endoflife.date/debian
 - https://endoflife.date/python

Finding Python version on distros:

 - https://packages.debian.org/trixie/python3
 - https://packages.ubuntu.com/resolute/python3
2026-08-04 09:08:19 -05:00
Jason LittleandGitHub 415a869f1f fix RemoteJoinHelper to handle v12 rooms (#20021)
While preparing for the default room version change to "12", the new
tests for
[FederationJoinUpgradedRoomTestCase](https://github.com/element-hq/synapse/blob/36664cac4fdec38993c68078cd9a82452b56dca7/tests/federation/test_federation_join_upgraded_room.py#L44)
were unable to handle creation events inside of the manufactured
`auth_events` sections. All of these tests fail.

Related to https://github.com/element-hq/synapse/pull/20015 as another
recent fix to `RemoteJoinHelper`


### Testing strategy

To test, I recommend changing the `DEFAULT_ROOM_VERSION` in [the
`server.py` config
file](https://github.com/element-hq/synapse/blob/36664cac4fdec38993c68078cd9a82452b56dca7/synapse/config/server.py#L179)
to `"12"`, then running `poetry run trial
tests.federation.test_federation_join_upgraded_room.FederationJoinUpgradedRoomTestCase`
for these selective tests. Alternatively, creating the
`default_config()` for the `TestCase` in question to set the default
room version, but that is more work.
2026-08-03 13:47:26 -05:00
Eric EastwoodandGitHub f61950d54d Fix release announcement to link to correct release branch of changelog (#20023)
Without this change, it was linking to `develop` as we were on the
`develop` branch because of the previous `merge-back` step at this point
in the release process.

Follow-up to https://github.com/element-hq/synapse/pull/19984 as this
was an oversight and I assumed we would still be on the `release-v1.158`
branch by that point.
2026-07-31 13:58:20 -05:00
Eric Eastwood e4644ae2b9 Remove duplicated punctuation v1.158.0rc1 2026-07-30 11:03:39 -05:00
Eric Eastwood 305e590bea Link and use canonical API name 2026-07-30 10:55:30 -05:00
Eric Eastwood 446bc852de Split #19898 changelog across two points 2026-07-30 10:52:13 -05:00
Eric Eastwood ade9176934 1.158.0rc1 2026-07-30 09:54:20 -05:00
Olivier 'reivilibreandGitHub 36664cac4f Add Module API hooks that notify modules when events are delivered over federation. (#20019)
Closes: https://github.com/element-hq/synapse/issues/19904

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-07-30 12:32:27 +01:00
Eric EastwoodandGitHub 897f68b3c2 Fix assertIncludes printing None at the end of the message (#20020) 2026-07-29 13:30:39 -05:00
Eric EastwoodandGitHub fba14358a7 Fix RemoteJoinHelper signing events with the default room version (room version mismatch) (#20015)
Fix `RemoteJoinHelper` signing events with mismatched room version
compared to the `room_version` arg. The default room version on
`develop` is `11` but the `RemoteJoinHelper` `room_version` arg defaults
to `10` (room version mismatch). This mismatch wasn't present where this
fix was developed
(https://github.com/element-hq/synapse-private/pull/136) as the default
room version was only recently bumped to `11` via
https://github.com/element-hq/synapse/pull/18680 (not even in a release
yet).

Fixes the CI being broken on `develop` :x::

```
[ERROR]
Traceback (most recent call last):
  File "/home/runner/work/synapse/synapse/tests/federation/test_federation_join_upgraded_room.py", line 298, in test_no_transfer_when_tombstone_does_not_match
    join_helper.join(local_user_id, local_user_tok)
  File "/home/runner/work/synapse/synapse/tests/federation/_remote_join.py", line 350, in join
    self._test_case.helper.join(remote_room_id, local_user_id, tok=local_user_tok)
  File "/home/runner/work/synapse/synapse/tests/rest/client/utils.py", line 195, in join
    return self.change_membership(
  File "/home/runner/work/synapse/synapse/tests/rest/client/utils.py", line 333, in change_membership
    assert channel.code == expect_code, (
builtins.AssertionError: Expected: 200, got: 400, PUT /_matrix/client/r0/rooms/!remote-room:other.example.com/state/m.room.member/@user1:test?access_token=syt_dXNlcjE_JSEarRndiAGqtydnrdLn_33qlLD -> resp: b'{"errcode":"M_UNKNOWN","error":"No create event in state"}'

tests.federation.test_federation_join_upgraded_room.FederationJoinUpgradedRoomTestCase.test_no_transfer_when_tombstone_does_not_match
```

These tests were originally introduced
https://github.com/element-hq/synapse-private/pull/136 (developed
private as this was part of the Synapse security release) and introduced
into the public codebase via
https://github.com/element-hq/synapse/commit/cbc6934821aab314506c5957223c60c74eeda091
2026-07-29 10:32:41 -05:00
dependabot[bot]andGitHub e3715b24fb Bump the patches group with 2 updates (#20012)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-29 09:30:21 +00:00
dependabot[bot]andGitHub 41c41d2c12 Bump quinn-proto from 0.11.14 to 0.11.16 (#20010)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-29 09:30:01 +00:00
Eric EastwoodandGitHub 1a1af7b622 Link to changelog instead of duplicating content in the tag/release (#19984)
This means we can point to a single source of truth instead of
duplicating the content to the tag and GitHub release. Less to manage
and worry about when you make some updates to the changelog (maintenance
burden). We also get to avoid the content sitting in the vendor lock-in
GitHub releases.

We point to
`https://github.com/element-hq/synapse/blob/{repo.active_branch.name}/CHANGES.md`
as it will have the relevant changelog entry at the top and won't change
as we archive releases on `develop`. Even for RC releases after the main
release goes out, the entry will still be towards the top. We could try
to get the heading anchor for the specific section but I thought that it
wasn't necessary (nice but more complex).
2026-07-28 15:44:26 -05:00
dependabot[bot]andGitHub 5d55a05f8e Bump regex from 1.12.4 to 1.13.0 (#20013)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 14:02:43 +00:00
Olivier 'reivilibre 9761f9bc42 Merge branch 'master' into develop 2026-07-28 14:39:05 +01:00
Olivier 'reivilibre 0c709bbb78 1.157.2 v1.157.2 2026-07-28 14:02:12 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 0a2456fef3 Validate room name, avatar and heroes' profile fields before sending down sliding sync as trusted fields
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-jhcg-5392-5mjw
Fixes: https://github.com/matrix-org/internal-config/issues/1751

I introduce some stricter JSON types that don't break down to `Any` — it seems these have become possible since our last attempt.
(I'm pretty sure mypy wouldn't let you do this a few years ago.)
Our `dict[str, Any]` type is such a footgun. I'd like to spread this out further, but will do so after the security release.

I then use these stricter JSON types on everything the sliding sync handler pulls out of `event.content` and therefore get forced into a bare minimum level of validation, by the type checker.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/151
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre c3adee3509 Restrict what errors we forward to clients from federation and policy servers
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-95fh-hv8c-chvq
Fixes: https://github.com/matrix-org/internal-config/issues/1721

https://github.com/element-hq/synapse-private/pull/158 is the end goal, I think

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/159
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 44216bf2b6 Limit the size of push rules
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-fp53-rw9v-hcf9
Fixes: https://github.com/matrix-org/internal-config/issues/1071

Because this is an out-of-spec limit and could break someone's workflow on release day, I've opted to make it configurable.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/149
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 4f8037ab59 Anchor the ends of our path patterns to prevent path traversal vulnerabilities
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-hgcg-p9gx-fq5f
Fixes: https://github.com/element-hq/backend-internal/issues/217 -> https://github.com/matrix-org/internal-config/issues/1760

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/146
2026-07-28 13:58:06 +01:00
cbc6934821 Prevent theft of room aliases via remote join to room with illegitimate predecessor
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-cjh7-rcpx-xpf8
Fixes: https://github.com/matrix-org/internal-config/issues/1729

---------

Co-authored-by: Eric Eastwood <erice@element.io>
Reviewed-on: https://github.com/element-hq/synapse-private/pull/136
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 68139e5234 Add missing 'event in expected room' check on /event_auth
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-qcjr-46gf-7f4r
Fixes: https://github.com/matrix-org/internal-config/issues/1714

The `/event_auth` endpoint could be tricked to give you the auth chain for an event in a foreign room,
because it trusted the requester to provide the correct `room_id` for the event.

Now we pass the `room_id` through all the way to `get_event`'s `check_room_id`, which (correctly IMO) treats mismatches as unknown events (seems correct as it prevents divulging what events we know about).

The `test_event_auth_wrong_room_returns_404` test failed before the fix.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/147
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 3772859fbc Add missing same-room check on /get_missing_events handler
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-27p5-4f45-gx76
Fixes: https://github.com/matrix-org/internal-config/issues/1717

I've tried my best to make the tests a good narrative for the thought process here,
but essentially the rationale is to make `/get_missing_events` not distinguish
between 'event is in wrong room' and 'event is unknown to me'.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/141
2026-07-28 13:58:06 +01:00
83672faf9c Add missing 'host in room' check for /timestamp_to_event/{roomId}
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-r66v-qhwx-8rg4
Fixes: https://github.com/matrix-org/internal-config/issues/1718

---------

Co-authored-by: Eric Eastwood <erice@element.io>
Reviewed-on: https://github.com/element-hq/synapse-private/pull/144
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre 51988c509f Fix spoofed to-device messages over federation not being dropped.
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-rgv2-84w7-5j9p
Fixes: https://github.com/matrix-org/internal-config/issues/1520
Introduced in: d4a35ada28

The code was obviously intended to drop them,
but the if block only logged without actually taking any action.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/145
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre e39303af40 Fix some paths being accessible at unintended locations with extra prefix components
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-vh4c-pqh4-w3wq
Fixes: https://github.com/matrix-org/internal-config/issues/1703

The key thing to understand is that in `synapse/util/httpresourcetree.py`,
we create `UnrecognizedRequestResource` and then dangle children (with real resources) off them.

Since `UnrecognizedRequestResource` returns itself as a catch-all 'dynamic child',
this means any `UnrecognizedRequestResource`s with real children can have unlimited path components inserted between it and its child.

So `/_matrix/INSERTED/static/client/login/style.css` or `/_matrix/INSERTED/AS/MANY/AS/I/WANT/static/client/login/style.css` would unexpectedly resolve to the resource.

Client, Federation and Admin APIs wouldn't have been affected because you wouldn't get through the regex routing that they use.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/143
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandOlivier 'reivilibre e860184067 Fix multipart/form-data mitigation being case-sensitive.
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-6wjm-9p2x-gvpm
Fixes: https://github.com/matrix-org/internal-config/issues/1740

Relevant library code to check against:

 - CPython `EmailMessage.get_content_type()`  (https://github.com/python/cpython/blob/v3.13.3/Lib/email/message.py#L608-L630)
 - Twisted `_parseContentType()` (https://github.com/twisted/twisted/blob/twisted-25.5.0/src/twisted/web/http.py#L306-L313)
 - Twisted `Request.requestReceived()` (https://github.com/twisted/twisted/blob/twisted-25.5.0/src/twisted/web/http.py#L1079-L1097)

-----

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
Reviewed-on: https://github.com/element-hq/synapse-private/pull/133
2026-07-28 13:58:06 +01:00