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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user