From 90e8b4534f18cb31dca3f4bd6d283e30bc0e08f0 Mon Sep 17 00:00:00 2001 From: Raphael Glon Date: Wed, 20 Aug 2025 11:20:08 +0200 Subject: [PATCH] fix(audio): strict base64 body input decoding Signed-off-by: Raphael Glon --- src/huggingface_inference_toolkit/webservice_starlette.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/huggingface_inference_toolkit/webservice_starlette.py b/src/huggingface_inference_toolkit/webservice_starlette.py index 6688ffa3..a0c3f5fd 100644 --- a/src/huggingface_inference_toolkit/webservice_starlette.py +++ b/src/huggingface_inference_toolkit/webservice_starlette.py @@ -101,8 +101,9 @@ async def predict(request): "automatic-speech-recognition", "audio-classification", }: + # Be more strict on base64 decoding, the provided string should valid base64 encoded data deserialized_body["inputs"] = base64.b64decode( - deserialized_body["inputs"] + deserialized_body["inputs"], validate=True ) # check for query parameter and add them to the body