Commit Graph
26205 Commits
Author SHA1 Message Date
Eric Eastwood 8d60450b33 Merge branch 'release-v1.164' into develop
Conflicts:
	CHANGES.md
	debian/changelog
2026-10-23 15:19:03 -05:00
Eric Eastwood aac366053f Merge branch 'master' into develop
Conflicts:
	pyproject.toml
2026-10-23 15:15:08 -05:00
Eric Eastwood 82c253f825 Clarify pillow bump only installable with Python >= 3.11 2026-10-23 15:01:53 -05:00
Eric Eastwood bcbf26641b Clarify pillow bump only installable with Python >= 3.11 2026-10-23 15:00:47 -05:00
Eric Eastwood 0a32d04b11 1.164.0rc3 v1.164.0rc3 2026-10-23 14:54:35 -05:00
Eric Eastwood 414abb9267 Bump pillow to version 13.0.0 with security fixes where Python support allows - Synapse 1.164.x (#20399)
The problem is that while `pillow@12.3.0` supports Python >= 3.10,
`pillow@13.0.0` only supports Python > 3.11, and we haven't dropped
support for Python 3.10 yet (tracked by
https://github.com/element-hq/synapse/issues/20041).

`pillow@13.0.0` includes some important security fixes:
https://pillow.readthedocs.io/en/stable/releasenotes/13.0.0.html

### How was this change made?

 1. `poetry update pillow`
1. Manually change the `"pillow"` `markers` in `poetry.lock` to split at
Python 3.11 instead of 3.14

Please note this is not a durable change. `poetry` will try to revert
this any time we try to make a change (requires diligence to make sure
we keep changing it back).

This maintenance burden will disappear once we drop Python 3.10 support
(tracked by https://github.com/element-hq/synapse/issues/20041).

### Alternatives

If we were up for updating the minimum version of `pillow` in
`pyproject.toml`, we could do something like the following which would
resolve in `poetry.lock` durably how we want,

`pyproject.toml`
```
    # Pillow 13 dropped Python 3.10 but has security fixes. Split so 3.11+ can pick up
    # the security fixes.
    #
    # FIXME: Remove the split once we drop Python 3.10 support.
    "Pillow>=10.0.1,<13; python_version < '3.11'",
    "Pillow>=13.0.0; python_version >= '3.11'",
```

It looks like we [previously
bumped](https://github.com/element-hq/synapse/blob/4853cd4238e100183fd7b0852ddf3e8eef894658/pyproject.toml#L54-L56)
the minimum version of `Pillow` for another CVE
(https://github.com/matrix-org/synapse/pull/16347)

Although, I'm guessing we'd rather leave the minimum version alone and
only update `poetry.lock`.

I think the problem with updating the minimum is that the packagers for
Linux distros will have to deal with not having the latest `pillow`
version available and may patch `pillow` a different way.
2026-10-23 14:52:14 -05:00
Eric Eastwood 62a411da7e 1.163.2 v1.163.2 2026-10-23 14:50:01 -05:00
Eric Eastwood f8a70f5424 Bump pillow to version 13.0.0 with security fixes where Python support allows (#20398)
The problem is that while `pillow@12.3.0` supports Python >= 3.10,
`pillow@13.0.0` only supports Python > 3.11, and we haven't dropped
support for Python 3.10 yet (tracked by
https://github.com/element-hq/synapse/issues/20041).

`pillow@13.0.0` includes some important security fixes:
https://pillow.readthedocs.io/en/stable/releasenotes/13.0.0.html

### How was this change made?

 1. `poetry update pillow`
1. Manually change the `"pillow"` `markers` in `poetry.lock` to split at
Python 3.11 instead of 3.14

Please note this is not a durable change. `poetry` will try to revert
this any time we try to make a change (requires diligence to make sure
we keep changing it back).

This maintenance burden will disappear once we drop Python 3.10 support
(tracked by https://github.com/element-hq/synapse/issues/20041).

### Alternatives

If we were up for updating the minimum version of `pillow` in
`pyproject.toml`, we could do something like the following which would
resolve in `poetry.lock` durably how we want,

`pyproject.toml`
```
    # Pillow 13 dropped Python 3.10 but has security fixes. Split so 3.11+ can pick up
    # the security fixes.
    #
    # FIXME: Remove the split once we drop Python 3.10 support.
    "Pillow>=10.0.1,<13; python_version < '3.11'",
    "Pillow>=13.0.0; python_version >= '3.11'",
```

It looks like we [previously
bumped](https://github.com/element-hq/synapse/blob/4853cd4238e100183fd7b0852ddf3e8eef894658/pyproject.toml#L54-L56)
the minimum version of `Pillow` for another CVE
(https://github.com/matrix-org/synapse/pull/16347)

Although, I'm guessing we'd rather leave the minimum version alone and
only update `poetry.lock`.

I think the problem with updating the minimum is that the packagers for
Linux distros will have to deal with not having the latest `pillow`
version available and may patch `pillow` a different way.
2026-10-23 14:48:11 -05:00
Junker der Provinz 4853cd4238 Remove $server_port from the Host header in the nginx reverse proxy example (#20391)
Fixes #19583

The nginx example in `docs/reverse_proxy.md` sets `proxy_set_header Host
$host:$server_port;`. The server block listens on 443, so nginx sends
`Host: matrix.example.com:443`. With `public_baseurl:
https://matrix.example.com/`, the request URI never starts with
`public_baseurl`, and `SsoRedirectServlet` keeps redirecting to itself.
That breaks SSO even when the internal and external ports are the same.
The line came in with #17994.

This switches the example to `proxy_set_header Host $host;`, as
@anoadragon453 recommended in #18359. I added a short comment for setups
where clients use a non-default port: use `$http_host` and put that port
in `public_baseurl`. The setup in #18359 (external port 50080) needs
that variant.

I left `docker/conf-workers/nginx.conf.j2` alone. Its listener port
matches `public_baseurl`, so `$host:$server_port` is right there.

This is a docs-only change, so there are no tests.

Thanks to @shibotto for reporting this and for pointing at the fix.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
2026-10-23 17:19:34 +00:00
Eric Eastwood 7ea942a5fe Merge branch 'release-v1.164' into develop
Conflicts:
	CHANGES.md
	debian/changelog
2026-10-22 14:51:16 -05:00
Eric Eastwood 06a1c55e56 1.164.0rc2 v1.164.0rc2 2026-10-22 14:32:23 -05:00
Eric Eastwood 2d7cccc87a Merge branch 'release-v1.164' of github.com:element-hq/synapse into release-v1.164 2026-10-22 14:30:33 -05:00
Eric Eastwood 603fb5bb39 Merge branch 'master' into develop
Conflicts:
	CHANGES.md
	debian/changelog
	pyproject.toml
2026-10-22 14:28:08 -05:00
Eric Eastwood b4daaca31f Update rustls-webpki to distrust eMudhra Intermediate certificates (#20392)
`rustls-webpki` releasenotes: https://github.com/rustls/webpki/releases/tag/v%2F0.103.16

Part of https://github.com/element-hq/backend-internal/issues/306

Related to https://github.com/element-hq/synapse/pull/20387

We already use the system CA store when making requests in our Rust code
(using the
[`rustls-tls-native-roots`](https://github.com/element-hq/synapse/blob/7c85c80033ea5c3ca3851f3dab1d0397b94d5183/rust/Cargo.toml#L61)
([docs](https://docs.rs/reqwest/0.12.28/reqwest/#optional-features))
feature with `reqwest`). For a system that already has a patched system
CA store, bumping `rustls-webpki` is simply extra protection as it
actively blocks those untrusted certs. For an unpatched system CA store,
this provides a stop-gap.


### Dev notes

```shell
$ cargo tree --invert rustls-webpki
rustls-webpki v0.103.16
└── rustls v0.23.45
    ├── hyper-rustls v0.27.7
    │   └── reqwest v0.12.28
    │       └── synapse v0.1.0 (/home/eric/Documents/github/element/synapse/rust)
    ├── reqwest v0.12.28 (*)
    └── tokio-rustls v0.26.2
        ├── hyper-rustls v0.27.7 (*)
        └── reqwest v0.12.28 (*)
```
2026-10-22 14:13:24 -05:00
Bardi Harborow c4680b6b81 security: update certifi to 2026.10.19 (#20387)
Updates `certifi` to 2026.10.19 to address
[GHSA-6q48-6c7w-9gw2](https://github.com/advisories/GHSA-6q48-6c7w-9gw2).

certifi before 2026.10.19 bundles `emSign ECC Root CA - G3`, which
chains to the compromised eMudhra intermediate CAs.

This only affects TLS connections made by the Sentry SDK when `sentry`
is configured, as `sentry_sdk`'s transport is the only runtime user of
certifi. Federation and Synapse's other outbound HTTP requests use the
system trust store via `platformTrust()`.

Python advisory:
https://discuss.python.org/t/information-for-python-users-regarding-emudhra-emsign-ca-certificate-security-incident/109576

---------

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
2026-10-22 14:13:24 -05:00
Eric Eastwood 56913c3d71 1.163.1 v1.163.1 2026-10-22 14:01:36 -05:00
Eric Eastwood 3f2bef9429 Update rustls-webpki to distrust eMudhra Intermediate certificates (#20392)
`rustls-webpki` releasenotes: https://github.com/rustls/webpki/releases/tag/v%2F0.103.16

Part of https://github.com/element-hq/backend-internal/issues/306

Related to https://github.com/element-hq/synapse/pull/20387

We already use the system CA store when making requests in our Rust code
(using the
[`rustls-tls-native-roots`](https://github.com/element-hq/synapse/blob/7c85c80033ea5c3ca3851f3dab1d0397b94d5183/rust/Cargo.toml#L61)
([docs](https://docs.rs/reqwest/0.12.28/reqwest/#optional-features))
feature with `reqwest`). For a system that already has a patched system
CA store, bumping `rustls-webpki` is simply extra protection as it
actively blocks those untrusted certs. For an unpatched system CA store,
this provides a stop-gap.


### Dev notes

```shell
$ cargo tree --invert rustls-webpki
rustls-webpki v0.103.16
└── rustls v0.23.45
    ├── hyper-rustls v0.27.7
    │   └── reqwest v0.12.28
    │       └── synapse v0.1.0 (/home/eric/Documents/github/element/synapse/rust)
    ├── reqwest v0.12.28 (*)
    └── tokio-rustls v0.26.2
        ├── hyper-rustls v0.27.7 (*)
        └── reqwest v0.12.28 (*)
```
2026-10-22 13:50:51 -05:00
Bardi Harborow c3adef6578 security: update certifi to 2026.10.19 (#20387)
Updates `certifi` to 2026.10.19 to address
[GHSA-6q48-6c7w-9gw2](https://github.com/advisories/GHSA-6q48-6c7w-9gw2).

certifi before 2026.10.19 bundles `emSign ECC Root CA - G3`, which
chains to the compromised eMudhra intermediate CAs.

This only affects TLS connections made by the Sentry SDK when `sentry`
is configured, as `sentry_sdk`'s transport is the only runtime user of
certifi. Federation and Synapse's other outbound HTTP requests use the
system trust store via `platformTrust()`.

Python advisory:
https://discuss.python.org/t/information-for-python-users-regarding-emudhra-emsign-ca-certificate-security-incident/109576

---------

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
2026-10-22 13:50:51 -05:00
Eric Eastwood 3366ea72cf Update rustls-webpki to distrust eMudhra Intermediate certificates (#20392)
`rustls-webpki` releasenotes: https://github.com/rustls/webpki/releases/tag/v%2F0.103.16

Part of https://github.com/element-hq/backend-internal/issues/306

Related to https://github.com/element-hq/synapse/pull/20387

We already use the system CA store when making requests in our Rust code
(using the
[`rustls-tls-native-roots`](https://github.com/element-hq/synapse/blob/7c85c80033ea5c3ca3851f3dab1d0397b94d5183/rust/Cargo.toml#L61)
([docs](https://docs.rs/reqwest/0.12.28/reqwest/#optional-features))
feature with `reqwest`). For a system that already has a patched system
CA store, bumping `rustls-webpki` is simply extra protection as it
actively blocks those untrusted certs. For an unpatched system CA store,
this provides a stop-gap.


### Dev notes

```shell
$ cargo tree --invert rustls-webpki
rustls-webpki v0.103.16
└── rustls v0.23.45
    ├── hyper-rustls v0.27.7
    │   └── reqwest v0.12.28
    │       └── synapse v0.1.0 (/home/eric/Documents/github/element/synapse/rust)
    ├── reqwest v0.12.28 (*)
    └── tokio-rustls v0.26.2
        ├── hyper-rustls v0.27.7 (*)
        └── reqwest v0.12.28 (*)
```
2026-10-22 09:49:50 -05:00
Johannes Marbach c54fd437e3 Switch the RTC notification rules to event-property-is (#20366)
As suggested in
https://github.com/matrix-org/matrix-spec-proposals/pull/4075#discussion_r4288130493.
2026-10-22 13:13:46 +01:00
Bardi Harborow 87b082f23a security: update certifi to 2026.10.19 (#20387)
Updates `certifi` to 2026.10.19 to address
[GHSA-6q48-6c7w-9gw2](https://github.com/advisories/GHSA-6q48-6c7w-9gw2).

certifi before 2026.10.19 bundles `emSign ECC Root CA - G3`, which
chains to the compromised eMudhra intermediate CAs.

This only affects TLS connections made by the Sentry SDK when `sentry`
is configured, as `sentry_sdk`'s transport is the only runtime user of
certifi. Federation and Synapse's other outbound HTTP requests use the
system trust store via `platformTrust()`.

Python advisory:
https://discuss.python.org/t/information-for-python-users-regarding-emudhra-emsign-ca-certificate-security-incident/109576

---------

Signed-off-by: Bardi Harborow <bardi@bardiharborow.com>
2026-10-21 19:29:23 -05:00
Olivier 'reivilibre 7c85c80033 Unbreak CI by bumping locked dependencies to support Python 3.15 wheels. (#20386)
It looks like our CI is sometimes being run with Python 3.15, where
`rpds-py` doesn't have wheels for our current version.

Unsure why it's intermittent.

Run:
https://github.com/element-hq/synapse/actions/runs/39464528041/job/118772376619

```
      | error: failed to run custom build command for `pyo3-ffi v0.27.2`
      | 
      | Caused by:
      |   process didn't exit successfully: `/tmp/tmp72_cy3_y/rpds_py-0.30.0/target/release/build/pyo3-ffi-ae84d9db989de8cd/build-script-build` (exit status: 1)
      |   --- stdout
      |   cargo:rustc-check-cfg=cfg(Py_LIMITED_API)
      |   cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)
      |   cargo:rustc-check-cfg=cfg(PyPy)
      |   cargo:rustc-check-cfg=cfg(GraalPy)
      |   cargo:rustc-check-cfg=cfg(py_sys_config, values("Py_DEBUG", "Py_REF_DEBUG", "Py_TRACE_REFS", "COUNT_ALLOCS"))
      |   cargo:rustc-check-cfg=cfg(pyo3_disable_reference_pool)
      |   cargo:rustc-check-cfg=cfg(pyo3_leak_on_drop_without_reference_pool)
      |   cargo:rustc-check-cfg=cfg(Py_3_7)
      |   cargo:rustc-check-cfg=cfg(Py_3_8)
      |   cargo:rustc-check-cfg=cfg(Py_3_9)
      |   cargo:rustc-check-cfg=cfg(Py_3_10)
      |   cargo:rustc-check-cfg=cfg(Py_3_11)
      |   cargo:rustc-check-cfg=cfg(Py_3_12)
      |   cargo:rustc-check-cfg=cfg(Py_3_13)
      |   cargo:rustc-check-cfg=cfg(Py_3_14)
      |   cargo:rustc-check-cfg=cfg(Py_3_15)
      |   cargo:rerun-if-env-changed=PYO3_CROSS
      |   cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
      |   cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
      |   cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
      |   cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG
      |   cargo:rerun-if-env-changed=PYO3_USE_ABI3_FORWARD_COMPATIBILITY
      | 
      |   --- stderr
      |   error: the configured Python version (3.15) is newer than PyO3's maximum supported version (3.14)
      |   = help: this package is being built with PyO3 version 0.27.2
      |   = help: check https://crates.io/crates/pyo3 for the latest PyO3 version available
      |   = help: updating this package to the latest version of PyO3 may provide compatibility with this Python version
      |   = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI
      | warning: build failed, waiting for other jobs to finish...
      | 💥 maturin failed
      |   Caused by: Failed to build a native library through cargo
      |   Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_BUILD_EXTENSION_MODULE="1" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.15-64bit" PYO3_PYTHON="/tmp/tmpy90bal2g/.venv/bin/python" PYTHON_SYS_EXECUTABLE="/tmp/tmpy90bal2g/.venv/bin/python" "cargo" "rustc" "--profile" "release" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/tmp72_cy3_y/rpds_py-0.30.0/Cargo.toml" "--lib"`
      | Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/tmpy90bal2g/.venv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
  
  Note: This error originates from the build backend, and is likely not a problem with poetry but one of the following issues with rpds-py (0.30.0)
  
    - not supporting PEP 517 builds
    - not specifying PEP 517 build requirements correctly
    - the build requirements are incompatible with your operating system or Python version
    - the build requirements are missing system dependencies (eg: compilers, libraries, headers).
  
  You can verify this by running pip wheel --no-cache-dir --use-pep517 "rpds-py (==0.30.0)".
  
  
  PEP517 build of a dependency failed
```


```
      | error: failed to run custom build command for `pyo3-ffi v0.26.0`
      | 
      | Caused by:
      |   process didn't exit successfully: `/tmp/tmpy_lu888j/pydantic_core-2.41.5/target/release/build/pyo3-ffi-83252c0f9cb4430a/build-script-build` (exit status: 1)
      |   --- stdout
      |   cargo:rustc-check-cfg=cfg(Py_LIMITED_API)
      |   cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)
      |   cargo:rustc-check-cfg=cfg(PyPy)
      |   cargo:rustc-check-cfg=cfg(GraalPy)
      |   cargo:rustc-check-cfg=cfg(py_sys_config, values("Py_DEBUG", "Py_REF_DEBUG", "Py_TRACE_REFS", "COUNT_ALLOCS"))
      |   cargo:rustc-check-cfg=cfg(pyo3_disable_reference_pool)
      |   cargo:rustc-check-cfg=cfg(pyo3_leak_on_drop_without_reference_pool)
      |   cargo:rustc-check-cfg=cfg(Py_3_7)
      |   cargo:rustc-check-cfg=cfg(Py_3_8)
      |   cargo:rustc-check-cfg=cfg(Py_3_9)
      |   cargo:rustc-check-cfg=cfg(Py_3_10)
      |   cargo:rustc-check-cfg=cfg(Py_3_11)
      |   cargo:rustc-check-cfg=cfg(Py_3_12)
      |   cargo:rustc-check-cfg=cfg(Py_3_13)
      |   cargo:rustc-check-cfg=cfg(Py_3_14)
      |   cargo:rustc-check-cfg=cfg(Py_3_15)
      |   cargo:rerun-if-env-changed=PYO3_CROSS
      |   cargo:rerun-if-env-changed=PYO3_CROSS_LIB_DIR
      |   cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_VERSION
      |   cargo:rerun-if-env-changed=PYO3_CROSS_PYTHON_IMPLEMENTATION
      |   cargo:rerun-if-env-changed=PYO3_PRINT_CONFIG
      |   cargo:rerun-if-env-changed=PYO3_USE_ABI3_FORWARD_COMPATIBILITY
      | 
      |   --- stderr
      |   error: the configured Python interpreter version (3.15) is newer than PyO3's maximum supported version (3.14)
      |   = help: please check if an updated version of PyO3 is available. Current version: 0.26.0
      |   = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI
      | warning: build failed, waiting for other jobs to finish...
      | 💥 maturin failed
      |   Caused by: Failed to build a native library through cargo
      |   Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_BUILD_EXTENSION_MODULE="1" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.15-64bit" PYO3_PYTHON="/tmp/tmprci5om5_/.venv/bin/python" PYTHON_SYS_EXECUTABLE="/tmp/tmprci5om5_/.venv/bin/python" "cargo" "rustc" "--profile" "release" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/tmpy_lu888j/pydantic_core-2.41.5/Cargo.toml" "--lib" "--crate-type" "cdylib"`
      | Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/tmprci5om5_/.venv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
  
  Note: This error originates from the build backend, and is likely not a problem with poetry but one of the following issues with pydantic-core (2.41.5)
  
    - not supporting PEP 517 builds
    - not specifying PEP 517 build requirements correctly
    - the build requirements are incompatible with your operating system or Python version
    - the build requirements are missing system dependencies (eg: compilers, libraries, headers).
  
  You can verify this by running pip wheel --no-cache-dir --use-pep517 "pydantic-core (==2.41.5)".
```

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-21 10:51:49 -05:00
Eric Eastwood 80d50913d6 Organize MSC4354 bugfixes with the others v1.164.0rc1 2026-10-20 09:54:17 -05:00
Eric Eastwood 7a7d81ce42 Link MSC4452 2026-10-20 09:51:46 -05:00
Eric Eastwood d053b37090 Lift new spec version advertisement to the top 2026-10-20 09:50:44 -05:00
Eric Eastwood 2e10fad626 We have enough context from the changelog entry for what MSC4140 is 2026-10-20 09:49:50 -05:00
Eric Eastwood 5df875ae67 Organize MSC4140 things together 2026-10-20 09:48:46 -05:00
Eric Eastwood d38f232372 Link MSC 2026-10-20 09:47:52 -05:00
Eric Eastwood 72c6a2cfb9 1.164.0rc1 2026-10-20 09:47:13 -05:00
Eric Eastwood 7d2e61abbb Correct docs for /redact_status failed_redactions/error (#20380)
Spawning from looking at these docs while looking at this area in
https://github.com/element-hq/synapse/pull/20379
2026-10-19 14:45:46 -05:00
Eric Eastwood cf306fbef6 Fix complete typo in redaction status admin API docs (#20379)
Fix https://github.com/element-hq/synapse/issues/18338
2026-10-19 12:09:02 -05:00
Erik Johnston eff0ecb062 Rust Postgres backend: value mapping and blocking runtime helpers (#19996)
Lays the two foundations the Rust DBAPI2 backend needs before any
connection code: a Python↔Postgres value-mapping layer, and the helpers
that drive async work from sync Python.

  Value mapping:
- `PgValue` — enum that implements `tokio_postgres::types::ToSql`,
encoding into Postgres' binary wire format per the prepared-statement
column type (so a single Python `int` becomes INT2/INT4/INT8 with range
checks).
- `PythonPgFromSql` — the decode counterpart, turning wire bytes back
into Python objects (SQL NULL → `None`).
- Covers int / float / bool / str / bytes / None; lists etc are left to
a follow-up.

  Blocking helpers:

- `block_on` / `block_on_pg_result` / `block_on_next` drive
`tokio-postgres` futures to completion from sync, GIL-holding Python
methods, releasing the GIL for the wait.

Both modules are `pub` for now so not-yet-consumed items don't trip
clippy's `dead_code` lint; later PRs in the stack tighten visibility.
Everything here is unit-tested with no live Postgres server.
2026-10-19 14:16:40 +01:00
7d44c81d5c Fix new state saved with the last local user's leave missing from state_after (#20314)
> [!NOTE]
> This PR will be rebased on `develop` once
https://github.com/element-hq/synapse/pull/20081 is merged

This PR is a follow up to
https://github.com/element-hq/synapse/pull/20081 and is based on its
code.
The scope of that original PR is limited to recovering the leave event
missing from `state_after`.

I noticed that state events from the leave event batch would only be
recovered if they were previously defined.

That made me add a pre-condition to the test: the topic had to be set
first.


https://github.com/element-hq/synapse/blob/bccf1679aed0a5d86de87165c548f8c459758055/tests/handlers/test_sync.py#L1096-L1099

This PR attempts to recover new state events that only appeared first in
the leave batch.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Fefaine <fefaine@gmail.com>
Co-authored-by: Quentin Gliech <quenting@element.io>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
Co-authored-by: Eric Eastwood <erice@element.io>
2026-10-19 09:25:23 +00:00
Paul Chobert 26a92c7111 MSC4140: Reject scheduling a delayed event that the sender could not send at that time (#20266)
## What the MSC says

From MSC4140's [Auth rule
evaluation](https://github.com/matrix-org/matrix-spec-proposals/blob/b7cb09664fed684388ba656459d08cfaf786c1d1/proposals/4140-delayed-events-futures.md#auth-rule-evaluation):

> The server SHOULD also check the event could be sent when it is
scheduled and reject the request if not. In particular, servers SHOULD
check the sender is in the room (or otherwise authorized to send the
event) to avoid storing events for rooms the user is not in.

## This PR

- Checks the event against the room's auth rules as if it were sent now,
and returns the same 403 `M_FORBIDDEN` that `/send` and `/state` would.
- Changes to the sender's own membership are exempt: a join or knock can
be sent from outside the room, which is how this PR reads the MSC's "or
otherwise authorized". They are checked by the auth rules when they are
sent.

Here are a few examples:

| Delayed event | Before | After |
| ----------------------------------------------------------------- |
--------------------------------------- |
---------------------------------------- |
| `m.room.message` from outside the room | 200 `delay_id`, fails at send
time | 403 `M_FORBIDDEN` |
| Kick of another member from outside the room | 200 `delay_id`, fails
at send time | 403 `M_FORBIDDEN` |
| `m.room.name` from a member whose power level is too low | 200
`delay_id`, fails at send time | 403 `M_FORBIDDEN` |
| **Exception**: join of a public room from outside it | 200 `delay_id`,
joins at send time | unchanged |
| Join from outside the room, then a message due after it | both
accepted, message sent once joined | join accepted, message 403
`M_FORBIDDEN` |
2026-10-16 14:38:12 +01:00
dependabot[bot] be306c5a16 Bump go.opentelemetry.io/otel/sdk from 1.43.0 to 1.45.0 in /complement (#20236) 2026-10-16 10:43:40 +00:00
Olivier 'reivilibre 4785f06e0e In legacy sync, lazy-load the memberships of the senders of MSC4354 Sticky Events. (#20362)
Part of: MSC4354 (Sticky Events, Experimental Feature tracking issue
#19409)

When a user is the sender of a sticky event that comes down sync, that
user is now in scope for having their lazy-loaded membership sent down
in sync.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-15 20:26:51 +01:00
Andrew Morgan 98735bc6db Remove remaining references to lxml python dependency, which is no longer required (#20356) 2026-10-15 12:54:54 +00:00
542554c093 MSC4242: State DAGs (inbound joins) (#20194)
Process inbound requests to join a state DAG room.

Split out from https://github.com/element-hq/synapse/pull/19425

Part of a series of 5x PRs to land the federation part of MSC4242
(https://github.com/element-hq/synapse/pull/19718,
https://github.com/element-hq/synapse/pull/20127,
https://github.com/element-hq/synapse/pull/20133, inbound-joins (this
PR), inbound-pulls).

Has some Complement tests:
```
PASS TestMSC4242JoinLeaveRejoinPublicRoom 9.19s
PASS TestMSC4242JoinPublicRoomWithRejectedStateDAGEvents 0.88s
```

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
Co-authored-by: Eric Eastwood <erice@element.io>
2026-10-15 13:17:08 +01:00
Olivier 'reivilibre b9b74e8892 Catch up historical MSC4354 Sticky Events to remote homeservers that are newly joining the room. (#20337)
Part of: MSC4354 (Experimental Feature tracking issue #19409)

Follows: #20165 (Sticky Event federation backlog + catch-up
transactions)


The MSC says that we need to tell a newly-joining server about all of
our sticky events (yes, even the ones before the server joined the
room).
This PR introduces the mechanism, building on the 'Sticky Event backlog'
mechanism introduced in #20165, to make that happen.

Most of the logic is taken from the original Sticky Events PR #18968,
but the Sticky Event backlog system did not exist back then.
(The benefit of having the persistent Sticky Event backlog is that we
don't need to rely on the federation senders not crashing to make sure
we get around to sending the Sticky Events out.)

- Add NEW_SERVER_JOINED replication command. (This is a cross-worker
'wake-up call' to check for a sticky event backlog)
We send it when persisting a state change that causes a new server to be
in the room.
We handle it by waking up federation senders for the destination,
including checking the sticky event backlog tables.

- When a server newly joins a room, we insert a sticky event backlog row
for that server, if there are any Sticky Events needing to be sent.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-15 09:53:02 +01:00
Olivier 'reivilibreandAndrew Morgan 1423a29f93 Reject null profile field values (following an optional clause in the specification), in order to avoid clients accidentally harming interoperability. (#20153)
Depends on: https://github.com/matrix-org/complement/pull/914

`displayname` and `avatar_url` already did not permit nulls, seemingly
from #8223.

The specification at v1.15 does not permit `null` for those fields
either, so this seems consistent with historical specification.

This only changes behaviour for 'custom' fields.

---------

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2026-10-15 09:52:28 +01:00
Olivier 'reivilibre e86eb378af Require a strictly positive stickiness duration for MSC4354 Sticky Events. (#20350)
Part of: MSC4354 (Sticky Events, Experimental Feature tracking issue
#19409)

Since a zero value would be meaningless, don't accept it.

Spawns from
https://github.com/matrix-org/matrix-spec-proposals/pull/4354#discussion_r4211703962

- MSC4354 Sticky Events: only strictly positive durations are valid

  MSC clarified in

https://github.com/matrix-org/matrix-spec-proposals/commit/2d1c3d646aae3738680f8a9a0ccb38b2d941a45f
  to require strict positivity!

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-15 09:51:56 +01:00
Olivier 'reivilibre 64689d45f4 Fix Sliding Sync considering a displayname/avatar change to mean the room was newly-joined (#20339)
Follows: #18375

This bugfix is a prerequisite for MSC4354 (Sticky Events, Experimental
Feature tracking issue #19409) changes.

- Add a failing test for join->join being newly_joined

- Fix the join->join transition being treated as a new join

  (when prev_events didn't coincidentally mask the problem)

  Rationale:

  `event_edges` / `prev_events` does NOT link a membership event
  to its previous state.
  (It could even be someone else's membership!)
In most real-world cases, this would generate a `prev_membership` of
NULL
  for every normal membership change.

  It appears as though the author intended some kind of 'previous state'
  relationship, but if you fix the first branch of the `UNION` query
  to use `current_state_delta_stream` for this (which is the source of
  state transitions), then it looks very redundant with the second
  branch.

It looks like the real reason we want to use the snapshots table is for
  out-of-band memberships (outlier memberships).
  So we continue using that for those, but ONLY for those.

  The `SUSPICIOUS` if block is removed because it appears to have been
papering over this issue by deduplicating the spurious `NULL` ->
non-null transitions,
but when you remove those duplicates at the source, it causes more
trouble
  because it doesn't know that what it's 'deduplicating' is actually the
  same membership transition.
This means if you join, then out-of-band leave (e.g. last member on the
server
to leave), that room would appear in `newly_joined` on a new initial
sync.
  (Tests did in fact catch this, too.)

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-15 09:48:51 +01:00
Eric Eastwood 0635bf67ba Merge branch 'master' into develop 2026-10-14 10:25:27 -05:00
Eric Eastwood 193cf9466f 1.163.0 v1.163.0 2026-10-14 09:22:00 -05:00
Eric Eastwood 2c52f9820e Constrain txredisapi version to avoid incompatible breaking changes in txredisapi@1.6.0 (#20354)
Fix https://github.com/element-hq/synapse/issues/20347

See
https://github.com/element-hq/synapse/issues/20347#issuecomment-6154861014
for more details.

Caused by the latest release of `txredisapi@1.6.0` (2026-10-09) which included https://github.com/IlyaSkriblovsky/txredisapi/pull/162

> May break compatibility with some specific user code because of inheritance changes.

And in the changelog:

> ### Incompatible changes
> 
> - Connections are maintained by
>   `twisted.application.internet.ClientService` now, and `RedisFactory` is no
>   longer a `ReconnectingClientFactory`. Code connecting a factory on its own
>   with `reactor.connectTCP()` or `twisted.application.internet.TCPClient` has
>   to use `factory.startConnecting(endpoint)` instead - see `examples/subscriber.py`
> 
> - `factory.continueTrying = False` is replaced by `factory.stopTrying()`;
>   `retry()`, `resetDelay()` and `delay` are gone. `maxDelay`, `initialDelay`,
>   `factor` and `jitter` still configure the backoff and are used by the new
>   `RedisFactory.retryDelay()`
> 
> - `SentinelConnectionFactory.try_to_connect()` is gone: the address of the
>   master or of a slave is discovered by the endpoint before every attempt.
>   Subclasses overriding `try_to_connect()`, `clientConnectionFailed()` or
>   `clientConnectionLost()` have no effect anymore
>
> [...]
>
> *-- [`IlyaSkriblovsky/txredisapi` -> *Release 1.6.0 (2026-10-09)*](https://github.com/IlyaSkriblovsky/txredisapi/blob/f844759b8aabc689eb87bf300ed3c675b84c3608/CHANGELOG.md#L31-L35)*




### Testing strategy

1. Check out the PR: `git checkout
madlittlemods/20347-txredisapi-constraint`
 1. Install into a fresh scratch venv:
     ```shell
    rm -rf /tmp/venv && python3 -m venv /tmp/venv
    /tmp/venv/bin/pip install '.[all]'
/tmp/venv/bin/pip show txredisapi | grep Version # expect 1.5.0 with
this PR
    ```
 1. One-time setup: make a homeserver config with Redis enabled:
    ```shell
    mkdir -p /tmp/hs && cd /tmp/hs
/tmp/venv/bin/python -m synapse.app.homeserver --server-name repro.test
\
        -c homeserver.yaml --generate-config --report-stats=no
printf '\nredis:\n enabled: true\n host: localhost\n' >> homeserver.yaml
    cd -
    ```
- On my machine, I also have to remove the IPv6 bind for `::1`, so `sed
-i '/^ - ::1$/d' /tmp/hs/homeserver.yaml`
1. Run Synapse: `/tmp/venv/bin/python -P -m synapse.app.homeserver -c
/tmp/hs/homeserver.yaml`
- It should run successfully with this PR. You can also check
`/tmp/hs/homeserver.log` for logs.

Repeat these steps on `develop` to see the original failure described in
https://github.com/element-hq/synapse/issues/20347 (`AttributeError:
'super' object has no attribute 'startedConnecting'. Did you mean:
'startConnecting'?`)
2026-10-14 08:47:40 -05:00
Paul Chobert d773067277 MSC4140: authenticate the delayed event management endpoints and allow guests (#20257) 2026-10-13 16:24:30 +00:00
Olivier 'reivilibre 636c6a3812 Stop reading from event_edges.is_state to prepare for dropping it. (#20069)
Gets one step further in the job started by
https://github.com/matrix-org/synapse/pull/12893

Part of: https://github.com/element-hq/synapse/issues/20026

## Manual testing strategy

Unfortunately it's quite difficult to actually trigger this.

You need to:

- check out an old full_schema, e.g. 54 which was present when `v1.62.0`
was released
- remove the version 72 `full_schema`, as it already has the background
update applied
- remove some deltas that are broken when upgrading across such a large
version gap (!) https://github.com/element-hq/synapse/issues/20070
- then run any trial test with Postgres enabled to prove that the
database schema applies

```
git checkout v1.62.0 -- synapse/storage/schema/state/full_schemas/54                
git checkout v1.62.0 -- synapse/storage/schema/main/full_schemas/54                                                                                                
git checkout v1.62.0 -- synapse/storage/schema/common/full_schemas/54
rm -r synapse/storage/schema/*/full_schemas/72
rm synapse/storage/schema/main/delta/58/10_pushrules_enabled_delete_obsolete.sql
rm synapse/storage/schema/main/delta/79/04_mitigate_stream_ordering_update_race.py
rm synapse/storage/schema/main/delta/56/redaction_censor3_fix_update.sql.postgres
rm synapse/storage/schema/main/delta/60/01recreate_stream_ordering.sql.postgres
SYNAPSE_TEST_LOG_LEVEL=DEBUG SYNAPSE_POSTGRES=1 poetry run trial tests.handlers.test_sliding_sync.ComputeInterestedRoomsTestCase_new.test_no_joins_after_to_token
```

As light validation, I purposefully inserted a SQL error into the query
to check that it is caught by the above testing strategy.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-10-13 11:56:10 +01:00
Paul Chobert 766f057305 Stop forwarding non compliant user ids (#20338)
Closes #20116

> [!NOTE]
> This PR Follows #20115 which already implemented this for
`m.device_list_update`

> User IDs with localparts containing characters outside the range
U+0021 to U+007E, or with
> an empty localpart, are considered non-compliant. For current room
versions, servers must
> still accept events using such user IDs over federation; however they
SHOULD NOT forward
> such user IDs to clients when referenced outside the context of an
event. For example,
> device list updates from non-compliant user IDs would be dropped by
the receiving server.
>
> — [Spec
1.19](https://spec.matrix.org/v1.19/appendices/#historical-user-ids)

This PR prevents from forwarding non compliant user ids for the
following events:

- `m.signing_key_update` 8c3c35e95d
- `m.presence` 26a8dfe862
- `m.typing` 1110cf2d73
- `m.receipt` 9e2da8b0a6
- `m.direct_to_device` 9541232a30
2026-10-13 11:10:48 +01:00
Richard van der Hoff 52f053abef Remove support for unstable MSC2965 (#20143)
These things are not needed now that MSC2965 has stabilised. In any
case, they
should never have been exposed without a config flag in the first place.
2026-10-12 16:43:38 +00:00
Will Hunt c52121d4b4 Add m.preview_url capability (Stabilise MSC4452) (#20298)
For https://github.com/element-hq/synapse/issues/19719

MSC4452 is now merged, so the stable capability can be made visible.
I've kept in the unstable flag in order to transition away at a later
date.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [ ] Pull request is based on the develop branch
* [ ] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [ ] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
2026-10-12 14:40:44 +01:00