fix: verify federation and enforce room access - #2
KyleDerZweite wants to merge 4 commits into
Conversation
Zusammenfassung der UmsetzungDer Federation-Meilenstein wurde auf dem aktuellen Serverstand geprüft und gehärtet.
Alle GitHub-CI-Prüfungen sind grün: Formatierung, Clippy, Tests, 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. |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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
docs/FEDERATION_SECURITY.md.Validation
Local validation passed with Rust 1.98.1, PostgreSQL 16, and Redis 7:
cargo fmt --all -- --checkSQLX_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 warningsscripts/sytest-smoke.shagainst an isolated database.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.