Skip to content

Require download.base_homeserver_url, remove per-origin media fetching - #145

Open
mxandreas wants to merge 1 commit into
element-hq:mainfrom
mxandreas:mxandreas/require-base-homeserver-url
Open

mxandreas wants to merge 1 commit into
element-hq:mainfrom
mxandreas:mxandreas/require-base-homeserver-url

Conversation

@mxandreas

Copy link
Copy Markdown
Member

Summary

  • download.base_homeserver_url is now a required configuration value (the download section itself is now required too).
  • All media downloads (both authenticated v1 and legacy v3 endpoints) now go exclusively through the configured base_homeserver_url. The .well-known discovery fallback and the direct https://<server_name> fallback have been removed, along with the now-dead _discover_via_well_known method and WellKnownDiscoveryError.
  • Rationale: previously, when base_homeserver_url was unset, the scanner resolved each media's origin homeserver from the (attacker-influenced) server_name in the mxc:// URI via .well-known discovery, or guessed https://<server_name> directly, and forwarded the client's Authorization header there. This could leak access tokens to a homeserver the operator never intended to trust. Media fetches now always go to the single, admin-configured, trusted homeserver, which is expected to proxy/fetch remote media on the scanner's behalf (as homeserver implementations like Synapse already do for both the legacy and authenticated media download endpoints).
  • Updated config.sample.yaml and README.md migration notes to reflect the new requirement.

Test plan

  • python -m unittest discover tests passes (57 tests)
  • ruff check clean
  • mypy shows no new errors (vs. main)
  • Built and ran the Docker image locally; confirmed the scanner starts and correctly downloads/scans media through a configured base_homeserver_url

…hing

Previously, if base_homeserver_url was left unset, the content scanner
would resolve each media's origin homeserver via .well-known discovery
(or a direct https://<server_name> guess) and forward the requester's
Authorization header there. Since server_name comes from the untrusted
mxc:// URI, this could send access tokens to a homeserver the operator
never intended to trust.

base_homeserver_url is now mandatory: every media fetch (authenticated
and legacy) goes through that single, admin-configured homeserver only,
which is expected to proxy/fetch remote media on the scanner's behalf.
The now-unreachable well-known discovery and direct-fetch fallback code
has been removed.
@mxandreas
mxandreas requested a review from a team as a code owner July 29, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant