From 7a0d413a8dbbe07dc9601986ecb079f8b10c0eb8 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 18 Nov 2025 14:20:46 -0800 Subject: [PATCH] Fixed SSERangeReader Infinite Loop Vulnerability --- weed/s3api/s3api_object_handlers.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index d49582074..bfbe1580d 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -3280,6 +3280,13 @@ func (r *SSERangeReader) Read(p []byte) (n int, err error) { if skipErr != nil { return 0, skipErr } + + // Guard against infinite loop: io.Reader may return (0, nil) + // which is permitted by the interface contract for non-empty buffers. + // If we get zero bytes without an error, treat it as an unexpected EOF. + if skipRead == 0 { + return 0, io.ErrUnexpectedEOF + } } // If we have a remaining limit and it's reached