From a288193cda769772dca472642e750e777279b30c Mon Sep 17 00:00:00 2001 From: kk10 Date: Sat, 10 Oct 2026 10:41:58 +0300 Subject: [PATCH] fix(httpx): reject request bodies with trailing data after JSON --- internal/httpx/request.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/httpx/request.go b/internal/httpx/request.go index 7a376e4..58f32b8 100644 --- a/internal/httpx/request.go +++ b/internal/httpx/request.go @@ -2,6 +2,8 @@ package httpx import ( "encoding/json" + "errors" + "io" "mime" "net/http" @@ -25,5 +27,10 @@ func DecodeJSONBody(w http.ResponseWriter, r *http.Request, requestID string, ds return false } + if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) { + WriteError(w, http.StatusBadRequest, dto.ErrorCodeInvalidRequest, "invalid request body", requestID) + return false + } + return true }