fix(federation): sign restricted join events before verification #1997
No reviewers
Labels
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Merge
Merge/Manual
Merge/Squash
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
bob the builder
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity!1997
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "eleboucher/continuwuity:fix-federation-signature"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Restricted room joins over federation between two continuwuity servers fail with M_INVALID_PARAM: Signature verification failed on membership event: Could not find signatures for entity.
Move the resident server's signing to the send_join route handler, before calling validate_any_membership_event with skip_verification=true. Then verify only the sender's signature via a new verify_event_for_server method.
Spec reference
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
@ -250,1 +244,4 @@// Verify only the sender's signature before adding our own for restricted// joins. The full signature check (including the authorising server's) is// done by other servers when they receive the event via /send.This comment is unnecessary/lacks sufficient context
sorry i should have started as draft this was my chain of thought comments :D
ab165deb521a2468bd3a1a2468bd3a67866ebd5d@ -120,3 +116,1 @@.map_err(|e| {err!(Request(InvalidParam(warn!("Failed to sign send_join event: {e}"))))})?;// The event was already signed by us in create_join_event_v2_route.I'm not really sure this is a sensible change. Moving the signature to earlier the call chain requires we parse the event a second time, and runs the risk of potentially leaking a signature on an invalid event (which we've had 2 CVEs for already)
okay let me change the logic quickly, it was my first draft which should make it better for this concern
here is my minimal implementation
@ -260,0 +257,4 @@.verify_event_for_server(sender.server_name(), &value).await.map_err(|e| {err!(Request(InvalidParam("Signature verification failed on membership event: {e}")))Not a huge fan of decentralising signature checks, the signature rules have changed before and it's plausible this code could fall behind. Can't we just sign the event before checking signatures? If the origin's signature is invalid it'll still error out, while retaining the herd safety of being checked by a central function
67866ebd5de576fb2efae576fb2efa23cb74b94823cb74b948944e6de4afI think this is fine, assuming callers of
validate_any_membership_eventcorrectly abort when the incoming event is found to be invalid later on (which I think they all do). I'll improve this whole system later to avoid this possibility in the first place944e6de4af3c607eea463c607eea468945cc9e10