Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make sure prev_ids defaults to empty list #12829

Merged
merged 2 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12829.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug where we did not correctly handle invalid device list updates over federation. Contributed by Carl Bordum Hansen.
4 changes: 4 additions & 0 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ async def incoming_device_list_update(
device_id = edu_content.pop("device_id")
stream_id = str(edu_content.pop("stream_id")) # They may come as ints
prev_ids = edu_content.pop("prev_id", [])
if not isinstance(prev_ids, list):
raise SynapseError(
400, "Device list update had an invalid 'prev_ids' field"
)
prev_ids = [str(p) for p in prev_ids] # They may come as ints

if get_domain_from_id(user_id) != origin:
Expand Down