BodySizeLimitInterceptor bypassed by missing or malformed Content-Length #4
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Location:
include/oatpp-authkit/interceptor/BodySizeLimitInterceptor.hpp:26-38The interceptor only inspects
Content-Lengthand silently passes requests with a missing or malformed header (the barecatch (...)then "let it through"). Trivial bypass via chunked transfer encoding or HTTP/2. A library named "body size limit" should either reject missing/unparsableContent-Lengthor measure streamed body size after parsing.From audit #1.
Agent Evaluation
Feasibility: Small. The interceptor is 30 lines; the change is in
intercept().Impact: Medium. The current behaviour is a misleading false-sense-of-security: a header named "body size limit" suggests it caps body size, but a request with no
Content-Length(or a malformed one) sails through, with a code-comment that even acknowledges this. Concrete bypasses: chunked transfer encoding, HTTP/2 (noContent-Lengthmandate), misbehaving clients, deliberate omission. Once bypassed, the body falls through to oatpp's much higher default ceiling. Tightening this closes a real hole for any consumer that thinks the interceptor is enforcing a hard cap.Effort: Small.
Recommendation: Accept.
Implementation plan
Content-Lengththe same as oversized: return411 Length Required(or413per consumer preference) by default. Add abool requireContentLengthctor flag (defaulttrueto fail-closed).Content-Length(current barecatch (...)) the same — reject as400 Bad Request. No more silent pass-through.Content-Length; consumers who need to support chunked transfer encoding should setrequireContentLength = falseand rely on a stream-layer guard.Decision needed
Check one (edit this comment):
Content-Lengthbecomes 411/400; consumers addrequireContentLength=falseif they need lax behaviour. Safer default; potentially breaks consumers that quietly relied on the bypass.requireContentLength=trueflag. Backwards-compatible; consumers who never opt in remain vulnerable. Defeats most of the point.Default recommendation: A. The library's purpose is hardened defaults; consumers who need the bypass can opt out explicitly.
Evaluated #4 — Small, recommend accept; A/B decision on fail-closed vs fail-open default.
Implemented #4 → commit
950012d, tag v0.3.4 (fail-closed default; legacy fail-open viarequireContentLength=false).