Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
14f13bab
Unverified
Commit
14f13bab
authored
5 years ago
by
Richard van der Hoff
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a test room version where we enforce key validity (#5348)
parent
2615c6bd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/5348.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/5348.bugfix
synapse/api/room_versions.py
+13
-7
13 additions, 7 deletions
synapse/api/room_versions.py
synapse/federation/federation_base.py
+24
-15
24 additions, 15 deletions
synapse/federation/federation_base.py
with
38 additions
and
22 deletions
changelog.d/5348.bugfix
0 → 100644
+
1
−
0
View file @
14f13bab
Add a new room version where the timestamps on events are checked against the validity periods on signing keys.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/api/room_versions.py
+
13
−
7
View file @
14f13bab
...
...
@@ -50,6 +50,7 @@ class RoomVersion(object):
disposition
=
attr
.
ib
()
# str; one of the RoomDispositions
event_format
=
attr
.
ib
()
# int; one of the EventFormatVersions
state_res
=
attr
.
ib
()
# int; one of the StateResolutionVersions
enforce_key_validity
=
attr
.
ib
()
# bool
class
RoomVersions
(
object
):
...
...
@@ -58,30 +59,35 @@ class RoomVersions(object):
RoomDisposition
.
STABLE
,
EventFormatVersions
.
V1
,
StateResolutionVersions
.
V1
,
)
STATE_V2_TEST
=
RoomVersion
(
"
state-v2-test
"
,
RoomDisposition
.
UNSTABLE
,
EventFormatVersions
.
V1
,
StateResolutionVersions
.
V2
,
enforce_key_validity
=
False
,
)
V2
=
RoomVersion
(
"
2
"
,
RoomDisposition
.
STABLE
,
EventFormatVersions
.
V1
,
StateResolutionVersions
.
V2
,
enforce_key_validity
=
False
,
)
V3
=
RoomVersion
(
"
3
"
,
RoomDisposition
.
STABLE
,
EventFormatVersions
.
V2
,
StateResolutionVersions
.
V2
,
enforce_key_validity
=
False
,
)
V4
=
RoomVersion
(
"
4
"
,
RoomDisposition
.
STABLE
,
EventFormatVersions
.
V3
,
StateResolutionVersions
.
V2
,
enforce_key_validity
=
False
,
)
VDH_TEST_KEY_VALIDITY
=
RoomVersion
(
"
vdh-test-key-validity
"
,
RoomDisposition
.
UNSTABLE
,
EventFormatVersions
.
V3
,
StateResolutionVersions
.
V2
,
enforce_key_validity
=
False
,
)
...
...
@@ -90,7 +96,7 @@ KNOWN_ROOM_VERSIONS = {
RoomVersions
.
V1
,
RoomVersions
.
V2
,
RoomVersions
.
V3
,
RoomVersions
.
STATE_V2_TEST
,
RoomVersions
.
V4
,
RoomVersions
.
VDH_TEST_KEY_VALIDITY
,
)
}
# type: dict[str, RoomVersion]
This diff is collapsed.
Click to expand it.
synapse/federation/federation_base.py
+
24
−
15
View file @
14f13bab
...
...
@@ -223,9 +223,6 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
the signatures are valid, or fail (with a SynapseError) if not.
"""
# (currently this is written assuming the v1 room structure; we'll probably want a
# separate function for checking v2 rooms)
# we want to check that the event is signed by:
#
# (a) the sender's server
...
...
@@ -257,6 +254,10 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
for
p
in
pdus
]
v
=
KNOWN_ROOM_VERSIONS
.
get
(
room_version
)
if
not
v
:
raise
RuntimeError
(
"
Unrecognized room version %s
"
%
(
room_version
,))
# First we check that the sender event is signed by the sender's domain
# (except if its a 3pid invite, in which case it may be sent by any server)
pdus_to_check_sender
=
[
...
...
@@ -264,10 +265,16 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
if
not
_is_invite_via_3pid
(
p
.
pdu
)
]
more_deferreds
=
keyring
.
verify_json_objects_for_server
([
(
p
.
sender_domain
,
p
.
redacted_pdu_json
,
0
)
for
p
in
pdus_to_check_sender
])
more_deferreds
=
keyring
.
verify_json_objects_for_server
(
[
(
p
.
sender_domain
,
p
.
redacted_pdu_json
,
p
.
pdu
.
origin_server_ts
if
v
.
enforce_key_validity
else
0
,
)
for
p
in
pdus_to_check_sender
]
)
def
sender_err
(
e
,
pdu_to_check
):
errmsg
=
"
event id %s: unable to verify signature for sender %s: %s
"
%
(
...
...
@@ -287,20 +294,22 @@ def _check_sigs_on_pdus(keyring, room_version, pdus):
# event id's domain (normally only the case for joins/leaves), and add additional
# checks. Only do this if the room version has a concept of event ID domain
# (ie, the room version uses old-style non-hash event IDs).
v
=
KNOWN_ROOM_VERSIONS
.
get
(
room_version
)
if
not
v
:
raise
RuntimeError
(
"
Unrecognized room version %s
"
%
(
room_version
,))
if
v
.
event_format
==
EventFormatVersions
.
V1
:
pdus_to_check_event_id
=
[
p
for
p
in
pdus_to_check
if
p
.
sender_domain
!=
get_domain_from_id
(
p
.
pdu
.
event_id
)
]
more_deferreds
=
keyring
.
verify_json_objects_for_server
([
(
get_domain_from_id
(
p
.
pdu
.
event_id
),
p
.
redacted_pdu_json
,
0
)
for
p
in
pdus_to_check_event_id
])
more_deferreds
=
keyring
.
verify_json_objects_for_server
(
[
(
get_domain_from_id
(
p
.
pdu
.
event_id
),
p
.
redacted_pdu_json
,
p
.
pdu
.
origin_server_ts
if
v
.
enforce_key_validity
else
0
,
)
for
p
in
pdus_to_check_event_id
]
)
def
event_err
(
e
,
pdu_to_check
):
errmsg
=
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment