From 87a686b644dec59f3ae2ceb104db943addc92766 Mon Sep 17 00:00:00 2001 From: Carl Bordum Hansen Date: Sat, 21 May 2022 17:18:23 +0200 Subject: [PATCH 1/2] Raise error if `prev_ids` is not a list Signed-off-by: Carl Bordum Hansen --- changelog.d/12829.bugfix | 2 ++ synapse/handlers/device.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelog.d/12829.bugfix diff --git a/changelog.d/12829.bugfix b/changelog.d/12829.bugfix new file mode 100644 index 000000000000..fc96de075295 --- /dev/null +++ b/changelog.d/12829.bugfix @@ -0,0 +1,2 @@ +Fixed a bug where device list updates over federation would fail if they +were not a list. Contributed by Carl Bordum Hansen. diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 1d6d1f8a9248..e59937fd755c 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -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: From cc22e56dfb89a9625917fcf725d887139e4a2477 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 25 May 2022 09:46:22 +0100 Subject: [PATCH 2/2] Update changelog.d/12829.bugfix --- changelog.d/12829.bugfix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changelog.d/12829.bugfix b/changelog.d/12829.bugfix index fc96de075295..dfa1fed34e01 100644 --- a/changelog.d/12829.bugfix +++ b/changelog.d/12829.bugfix @@ -1,2 +1 @@ -Fixed a bug where device list updates over federation would fail if they -were not a list. Contributed by Carl Bordum Hansen. +Fix a bug where we did not correctly handle invalid device list updates over federation. Contributed by Carl Bordum Hansen.