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

Commit 862b2f9

Browse files
authored
Merge pull request #5307 from matrix-org/rav/server_keys/07-fix-notary-cache-poison
Stop overwriting server keys with other keys
2 parents 2889b05 + 3600f55 commit 862b2f9

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

changelog.d/5307.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where a notary server would sometimes forget old keys.

synapse/crypto/keyring.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def __init__(self, hs):
399399

400400
@defer.inlineCallbacks
401401
def process_v2_response(
402-
self, from_server, response_json, time_added_ms, requested_ids=[]
402+
self, from_server, response_json, time_added_ms
403403
):
404404
"""Parse a 'Server Keys' structure from the result of a /key request
405405
@@ -422,10 +422,6 @@ def process_v2_response(
422422
423423
time_added_ms (int): the timestamp to record in server_keys_json
424424
425-
requested_ids (iterable[str]): a list of the key IDs that were requested.
426-
We will store the json for these key ids as well as any that are
427-
actually in the response
428-
429425
Returns:
430426
Deferred[dict[str, FetchKeyResult]]: map from key_id to result object
431427
"""
@@ -481,11 +477,6 @@ def process_v2_response(
481477

482478
signed_key_json_bytes = encode_canonical_json(signed_key_json)
483479

484-
# for reasons I don't quite understand, we store this json for the key ids we
485-
# requested, as well as those we got.
486-
updated_key_ids = set(requested_ids)
487-
updated_key_ids.update(verify_keys)
488-
489480
yield logcontext.make_deferred_yieldable(
490481
defer.gatherResults(
491482
[
@@ -498,7 +489,7 @@ def process_v2_response(
498489
ts_expires_ms=ts_valid_until_ms,
499490
key_json_bytes=signed_key_json_bytes,
500491
)
501-
for key_id in updated_key_ids
492+
for key_id in verify_keys
502493
],
503494
consumeErrors=True,
504495
).addErrback(unwrapFirstError)
@@ -754,7 +745,6 @@ def get_server_verify_key_v2_direct(self, server_name, key_ids):
754745

755746
response_keys = yield self.process_v2_response(
756747
from_server=server_name,
757-
requested_ids=[requested_key_id],
758748
response_json=response,
759749
time_added_ms=time_now_ms,
760750
)

0 commit comments

Comments
 (0)