From e542be17addeb0b47d3cbaf18ebe50d0f3ceabad Mon Sep 17 00:00:00 2001 From: Mubashir Osmani Date: Thu, 2 Jul 2026 01:12:49 +0000 Subject: [PATCH] fix(s3_v2): pass usedforsecurity=False to hashlib.md5 for FIPS envs Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/integrations/s3_v2.py | 8 ++++++-- tests/test_litellm/integrations/test_s3_v2.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/litellm/integrations/s3_v2.py b/litellm/integrations/s3_v2.py index db12d1d2c26..5b953035cfd 100644 --- a/litellm/integrations/s3_v2.py +++ b/litellm/integrations/s3_v2.py @@ -323,7 +323,9 @@ class S3Logger(CustomBatchLogger, BaseAWSLLM): # Calculate SHA256 hash of the content content_hash = hashlib.sha256(json_string.encode("utf-8")).hexdigest() - content_md5 = base64.b64encode(hashlib.md5(json_string.encode("utf-8")).digest()).decode() + content_md5 = base64.b64encode( + hashlib.md5(json_string.encode("utf-8"), usedforsecurity=False).digest() + ).decode() # Prepare the request headers = { @@ -496,7 +498,9 @@ class S3Logger(CustomBatchLogger, BaseAWSLLM): # Calculate SHA256 hash of the content content_hash = hashlib.sha256(json_string.encode("utf-8")).hexdigest() - content_md5 = base64.b64encode(hashlib.md5(json_string.encode("utf-8")).digest()).decode() + content_md5 = base64.b64encode( + hashlib.md5(json_string.encode("utf-8"), usedforsecurity=False).digest() + ).decode() # Prepare the request headers = { diff --git a/tests/test_litellm/integrations/test_s3_v2.py b/tests/test_litellm/integrations/test_s3_v2.py index 3331f9f4f5e..070e278cdc0 100644 --- a/tests/test_litellm/integrations/test_s3_v2.py +++ b/tests/test_litellm/integrations/test_s3_v2.py @@ -1203,7 +1203,9 @@ def _expected_content_md5(payload: dict) -> str: from litellm.litellm_core_utils.safe_json_dumps import safe_dumps json_string = safe_dumps(payload) - return base64.b64encode(hashlib.md5(json_string.encode("utf-8")).digest()).decode() + return base64.b64encode( + hashlib.md5(json_string.encode("utf-8"), usedforsecurity=False).digest() + ).decode() @pytest.mark.asyncio