Skip to content

fix: verify federation and enforce room access - #2

Open
KyleDerZweite wants to merge 4 commits into
mainfrom
codex/federation-milestone1-hardening
Open

KyleDerZweite wants to merge 4 commits into
mainfrom
codex/federation-milestone1-hardening

Conversation

@KyleDerZweite

@KyleDerZweite KyleDerZweite commented Sep 14, 2026

Copy link
Copy Markdown
Member

Federation routes previously trusted the shape of an X-Matrix header, and joined users could write room state or moderate other members without checking power levels. This change verifies request and event signatures and authorizes room access and mutations against locked room state.

Changes

  • Verify Ed25519 signatures over the exact request method, encoded URI/query, origin, destination, and canonical content. Validate HTTPS key documents, identity, self-signatures, expiry, rotation, and cached keys; constrain discovery destinations and response sizes.
  • Check room participation, federation flags, and server ACLs. Verify v11 PDU signatures, content hashes, reference IDs, and current authorization before atomic persistence. Emit correctly signed v11 wire PDUs without storage-only event IDs.
  • Enforce local and federated membership and power-level rules, including generic state routes and effective default roles. Make message retries atomic and return the original persisted event ID.
  • Enforce historical message visibility across messages, sync, and federation reads. Isolate unverifiable legacy timelines in sync and preserve queued device messages when room assembly fails.
  • Run database and production-router security regressions in CI, and document the supported subset in docs/FEDERATION_SECURITY.md.

Validation

Local validation passed with Rust 1.98.1, PostgreSQL 16, and Redis 7:

  • cargo fmt --all -- --check
  • SQLX_OFFLINE=true cargo test --workspace --all-targets --locked: 49 tests passed, including 9 HTTP route scenarios with real PostgreSQL/Redis.
  • SQLX_OFFLINE=true cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • Built server startup and scripts/sytest-smoke.sh against an isolated database.
  • Independent Astra High review, followed by fixes and regression coverage for every concrete finding.

The HTTP fixture pins a signed key document published by a second server identity. It tests the production Axum router, not public TLS discovery or interoperability with an independent homeserver implementation.

Supported boundary

This remains an experimental room-v11 subset. Incoming events must extend the verified current linear chain. Remote room bootstrap, historical state reconstruction, stale/forked histories, and unsupported membership proofs are rejected until auth-chain validation and state resolution are implemented. Complete Matrix/Sytest/Complement conformance is not claimed.

Existing events without verifiable depth/predecessor ordering remain stored, but their historical reads are denied. Sync omits only the affected timeline and continues delivering other rooms and device messages. Current deployment data is confirmed to be test data; no migration is included. Private-address federation and SRV discovery remain unsupported.

@KyleDerZweite

Copy link
Copy Markdown
Member Author

Zusammenfassung der Umsetzung

Der Federation-Meilenstein wurde auf dem aktuellen Serverstand geprüft und gehärtet.

  • Den Abhängigkeitszyklus zwischen vauxl-federation und vauxl-matrix behoben.
  • Ausgehende make_join- und send_join-Anfragen werden signiert.
  • X-Matrix-Authentifizierung sowie Server-, Raum-, Benutzer-, Ereignis- und PDU-Identitäten werden geprüft.
  • Ungültige Anfragen, inkonsistente Pfad- und Body-Werte sowie nicht erfolgreiche Schlüsselantworten werden abgewiesen.
  • reqwest auf 0.12 aktualisiert und veraltete TLS-Abhängigkeiten entfernt.
  • Die nicht verfügbare Sytest-Action durch reproduzierbare lokale Matrix-Smoke-Checks mit PostgreSQL und Redis ersetzt.
  • Die Smoke-Checks sind jetzt erforderlich und schlagen bei echten Fehlern fehl.

Alle GitHub-CI-Prüfungen sind grün: Formatierung, Clippy, Tests, cargo-deny und Matrix-Smoke-Checks.

Die vollständige P1-020-Abnahme benötigt weiterhin echte kryptografische Signaturprüfung für S2S-Anfragen und PDUs sowie einen authentifizierten Test zwischen zwei Homeservern.

@KyleDerZweite KyleDerZweite left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: cryptographic federation authentication remains a release blocker for public federation

Correction to my earlier merge assessment: request signature verification was already absent on the base branch, and this PR explicitly lists cryptographic request/PDU verification and authenticated two-homeserver testing as unfinished P1-020 work. My previous wording overstated this finding as a reason to block merging this incremental PR. It describes a pre-existing gap, not an established regression introduced by this diff.

At the reviewed head 0697e16, require_federation_origin in crates/vauxl-matrix/src/routes/federation.rs:788 parses the X-Matrix fields and checks the destination, but does not cryptographically verify the signature. A syntactically accepted, non-empty sig therefore does not authenticate the claimed origin. Before exposing federation, verify the signed request against its method, URI, origin, destination, and content using the appropriate validated server key, and reject invalid signatures before processing events or disclosing room state. PDU signature checks, Matrix event authorization, and authenticated two-homeserver interoperability remain separate acceptance requirements.

The PR's dependency-cycle fix, outgoing signing, and additional shape/identity validation are useful incremental improvements. Previously run local review checks passed formatting, the federation/matrix/server test targets, and strict Clippy for vauxl-server. Full local workspace validation was limited by missing pkg-config/OpenSSL development dependencies in the identity/admin dependency path. The green discovery smoke workflow does not exercise cryptographic authentication or establish Matrix conformance.

@KyleDerZweite KyleDerZweite changed the title fix: harden federation milestone implementation fix: verify federation and enforce room access Sep 15, 2026

@KyleDerZweite KyleDerZweite left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nachprüfung von 52bb91c: Die zuvor gemeldete fehlende kryptografische Prüfung von Föderationsanfragen ist behoben. Request- und PDU-Signaturen werden geprüft; nicht verifizierbare Anfragen werden vor Raumzugriffen oder Änderungen abgewiesen.

Weitere behobene Befunde:

  • Raumänderungen und Mitgliedschaftsaktionen prüfen Berechtigungen unter derselben Datenbanksperre wie die Speicherung. Die Umgehung über effektive Standard-Power-Level ist geschlossen.
  • Nachrichtenhistorie berücksichtigt die damalige Mitgliedschaft und Sichtbarkeit. Nicht überprüfbare Altverläufe bleiben gespeichert, werden aber gesperrt; Sync liefert andere Räume und Gerätenachrichten weiterhin aus.
  • Server-ACLs weisen auch alternative IPv4-Schreibweisen ab. Föderationsantworten liefern verifizierbare v11-PDUs ohne das nur intern gespeicherte event_id.
  • Nachrichtenwiederholungen speichern Ereignis und Transaktionskennung atomar und liefern die ursprüngliche Ereignis-ID zurück.

Validierung: 49 lokale Workspace-Tests bestanden, darunter 9 HTTP-Sicherheitsszenarien über den tatsächlichen Server-Router mit PostgreSQL und Redis. Formatierung, striktes Clippy und der Server-Smoke-Test bestanden ebenfalls. Alle CI-Checks und Matrix-Smoke-Checks auf diesem Commit sind grün. Die unabhängige Astra-High-Nachprüfung hat nach den Korrekturen keine offenen konkreten Befunde im vereinbarten Umfang ergeben.

Vereinbarte Grenze: experimentelle, lineare Raum-v11-Unterstützung. Unverifizierbare Remote-Joins, historische Zustandsrekonstruktion und verzweigte Historien werden abgewiesen. Vollständige Auth-Chain-Prüfung, Zustandsauflösung und Interoperabilität bleiben Folgearbeit. Die HTTP-Tests verwenden ein in Redis hinterlegtes signiertes Peer-Schlüsseldokument; sie belegen keine öffentliche TLS-Discovery oder Interoperabilität mit einer unabhängigen Homeserver-Implementierung. Details: FEDERATION_SECURITY.md.

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