Skip to content

Commit 08f4f9e

Browse files
committed
Give allocation back if signature validation fails
1 parent d9baf10 commit 08f4f9e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

hub/peer_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ async def check_request_signature(self, raw_request: fastapi.Request):
106106
computed_signature = signing_key.sign([query, body])
107107
signature_ok = received_signature.same_as(computed_signature)
108108
if not signature_ok:
109-
# TODO: Give allocation back to pool
109+
# If the signature validation fails, we give the allocation for the signing key
110+
# back to the pool. This is to prevent an attacker exhausting the pool (denial of
111+
# service) by sending lots of badly signed messages.
112+
allocation.give_back()
110113
LOGGER.warning(
111114
f"Invalid signature received from peer client '{self._client_name}'"
112115
)

0 commit comments

Comments
 (0)