Skip to content

Commit

Permalink
Ignore attempts to send to-device messages to bad users (element-hq#1…
Browse files Browse the repository at this point in the history
…7240)

Currently sending a to-device message to a user ID with a dodgy
destination is accepted, but then ends up spamming the logs when we try
and send to the destination.

An alternative would be to reject the request, but I'm slightly nervous
that could break things.
  • Loading branch information
erikjohnston authored and H-Shay committed May 31, 2024
1 parent 20526d3 commit f26862f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/17240.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore attempts to send to-device messages to bad users, to avoid log spam when we try to connect to the bad server.
7 changes: 7 additions & 0 deletions synapse/handlers/devicemessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ async def send_device_message(
local_messages = {}
remote_messages: Dict[str, Dict[str, Dict[str, JsonDict]]] = {}
for user_id, by_device in messages.items():
if not UserID.is_valid(user_id):
logger.warning(
"Ignoring attempt to send device message to invalid user: %r",
user_id,
)
continue

# add an opentracing log entry for each message
for device_id, message_content in by_device.items():
log_kv(
Expand Down

0 comments on commit f26862f

Please sign in to comment.