From 8093b598c3a11681df46fc0d281f4c97ffb23086 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 25 Oct 2026 20:05:29 +0100 Subject: [PATCH] fix(runtime): close chunk-size cap-check overflow in FeedChunkSize body_.size() + size could wrap size_t when an attacker-controlled chunk size (up to 0xFFFFFFFFFFFFFFFF) was added to an already non-empty body, making the body_cap_ comparison pass when it should reject with 413. Check the remaining budget instead of the sum: reject if body_ already exceeds the cap, or if the declared chunk size exceeds what's left. Co-Authored-By: Claude Sonnet 5 --- src/runtime/http/v1/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/http/v1/parser.cpp b/src/runtime/http/v1/parser.cpp index 115967c..a7fbc01 100644 --- a/src/runtime/http/v1/parser.cpp +++ b/src/runtime/http/v1/parser.cpp @@ -345,7 +345,7 @@ ParseResult Parser::FeedChunkSize() { state_ = State::Trailers; return ParseResult::NeedMore; } - if (body_.size() + size > body_cap_) { + if (body_.size() > body_cap_ || size > body_cap_ - body_.size()) { state_ = State::Failed; return ParseResult::Error413; }