element-hq / element-hq/synapse

Spec compliance: synapse does not appear to correctly enforce strict canonicaljson in federation requests, etc

Open
#13,883 0 comments 0 reactions 0 assignees View on GitHub
A-Spec-Compliance O-Uncommon S-Tolerable T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#13883](https://github.com/matrix-org/synapse/issues/13883).

---

The [canonicaljson spec](https://spec.matrix.org/v1.3/appendices/#canonical-json) says that json requests cannot contain:

* Integers outside the range `[-2 ^ 53 + 1, 2 ^ 53 - 1]`
* Floats
* NaN, Infinity, -Infinity

... which should mean that it is impossible to sign a federation request containing such values, so all such requests should be rejected. However AFAICT Synapse does not enforce this.

Canonicaljson is used in a couple of other places too (3pid invites, E2EE, etc), and the same considerations apply there.

Contributor guide

Open the contributing guide

Research direction

Start with the linked canonicaljson specification and audit Synapse's federation-request, 3pid-invite, and E2EE signing paths. Verify how each path handles out-of-range integers, floats, NaN, Infinity, and -Infinity, then confirm that every affected request is rejected consistently and add coverage for the discovered cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, distributed-systems, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.