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

Commit 00bf99f

Browse files
committed
cap the validity_ts on server signing keys
... as per matrix-org/matrix-spec-proposals#2075
1 parent dae224a commit 00bf99f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.d/5348.bugfix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ensure that we have an up-to-date copy of the signing key when validating incoming federation requests.
2+

synapse/crypto/keyring.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
from synapse.util.metrics import Measure
5757
from synapse.util.retryutils import NotRetryingDestination
5858

59+
# the maximum amount of time we cache a signing key for, before we consider it invalid.
60+
MAX_KEY_VALID_MS = 7 * 24 * 3600 * 1000
61+
5962
logger = logging.getLogger(__name__)
6063

6164

@@ -483,6 +486,9 @@ def process_v2_response(
483486
"""
484487
ts_valid_until_ms = response_json[u"valid_until_ts"]
485488

489+
# cap the ts_valid_until_ms, to stop people poisoning our cache forever
490+
ts_valid_until_ms = min(ts_valid_until_ms, time_added_ms + MAX_KEY_VALID_MS)
491+
486492
# start by extracting the keys from the response, since they may be required
487493
# to validate the signature on the response.
488494
verify_keys = {}

0 commit comments

Comments
 (0)