Skip to content

Commit 61f267c

Browse files
committed
Always check the signature
1 parent 2456537 commit 61f267c

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

  • app/grandchallenge/components/backends

app/grandchallenge/components/backends/base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,17 +818,14 @@ def _get_task_return_code(self):
818818

819819
body = response["Body"].read()
820820

821-
signature_hmac_sha256 = response["Metadata"].get(
822-
"signature_hmac_sha256"
823-
)
821+
signature_hmac_sha256 = response["Metadata"]["signature_hmac_sha256"]
824822
body_signature_hmac_sha256 = hmac.new(
825823
key=self._signing_key, msg=body, digestmod=hashlib.sha256
826824
).hexdigest()
827825

828-
if signature_hmac_sha256 and not secrets.compare_digest(
826+
if not secrets.compare_digest(
829827
body_signature_hmac_sha256, signature_hmac_sha256
830828
):
831-
# TODO The signature should always be present when all images use sagemaker shim >= 0.5.0
832829
logger.error(
833830
"The invocation response object has been tampered with"
834831
)

0 commit comments

Comments
 (0)