Skip to content

Better specify how to validate events #365

@richvdh

Description

@richvdh

We should clearly specify how to validate an event that has been received over federation, and how the receiving server should behave when validation fails.

The sorts of things we should consider checking include:

  • json compliance:
    • does it conform to the rules of canonicaljson (eg no floats, no bigints)?
    • Does it have invalid UTF-8 (invalid byte sequences, overlong encodings, things which decode to the UTF-16 surrogates or to codepoints above U+10FFFF)?
  • schema compliance:
  • whether the origin matches the sender sending the event, for pushed transactions.
  • whether the sender and event_id match the origin (except for join events)
  • whether the creator on a create event matches the sender and the room_id
  • whether it has a "sensible" number of prev_events
  • signatures: whether the event has been signed by the origin (and the sender's server, where different).
    • also, whether the signing key was valid at the time the signature was made.
  • hashes: whether the event's content matches the content hash
  • whether hashes in prev_events and auth_events correspond to the hashes on events we have (though this will probably be made much simpler by MSC: Replace event IDs with hashes matrix-spec-proposals#1640)

Parts of this list overlap with the rules already set out for Authorization of PDUs.

Synapse currently checks many, but not all, of the things on this list, so there may well be rooms in existence which do not conform. Starting to check them now is problematic in that it may prevent servers from participating in those existing rooms. We should therefore consider whether it is reasonable to apply any additional checks now, or which should wait for a future room version.

We should also define the behaviour when a validation check is not met: should we ignore such events, or reject incoming pushes? For pulls, should we try to get the events from elsewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-S2SServer-to-Server API (federation)clarificationAn area where the expected behaviour is understood, but the spec could do with being more explicitfeatureSuggestion for a significant extension which needs considerable consideration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions