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

Commit

Permalink
cap the validity_ts on server signing keys
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Jun 4, 2019
1 parent dae224a commit 00bf99f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog.d/5348.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ensure that we have an up-to-date copy of the signing key when validating incoming federation requests.

6 changes: 6 additions & 0 deletions synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
from synapse.util.metrics import Measure
from synapse.util.retryutils import NotRetryingDestination

# the maximum amount of time we cache a signing key for, before we consider it invalid.
MAX_KEY_VALID_MS = 7 * 24 * 3600 * 1000

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -483,6 +486,9 @@ def process_v2_response(
"""
ts_valid_until_ms = response_json[u"valid_until_ts"]

# cap the ts_valid_until_ms, to stop people poisoning our cache forever
ts_valid_until_ms = min(ts_valid_until_ms, time_added_ms + MAX_KEY_VALID_MS)

# start by extracting the keys from the response, since they may be required
# to validate the signature on the response.
verify_keys = {}
Expand Down

0 comments on commit 00bf99f

Please sign in to comment.