security: address medium risks in jwt, redis ordering and body limit

This commit is contained in:
Naeel
2026-04-10 19:44:34 +03:00
parent a5e9bfb15c
commit 3b4fe0bb3a
3 changed files with 61 additions and 3 deletions
+3 -3
View File
@@ -26,7 +26,7 @@ import (
func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler {
r := mux.NewRouter()
// Fix #3.5: глобальный лимит размера тела HTTP запроса — 1MB
// Fix #3.5: глобальный лимит размера тела HTTP запроса — 3MB
// Защита от OOM при отправке гигантских batch/message requests
r.Use(requestBodyLimitMiddleware)
@@ -57,12 +57,12 @@ func New(tenantStore *tenant.TenantStore, adminToken string) http.Handler {
return r
}
// requestBodyLimitMiddleware — ограничивает размер тела HTTP запроса до 1MB.
// requestBodyLimitMiddleware — ограничивает размер тела HTTP запроса до 3MB.
// Защита от OOM при отправке гигантских messages/batch (Fix #3.5).
func requestBodyLimitMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Body != nil {
r.Body = http.MaxBytesReader(w, r.Body, 1*1024*1024) // 1MB
r.Body = http.MaxBytesReader(w, r.Body, 3*1024*1024) // 3MB
}
next.ServeHTTP(w, r)
})