Repository navigation
Description
Is there an existing issue for this?
- I searched open and closed issues for headerMaxSize and header-name size accounting; no matching report was found.
- [BUG] Divide requestMaxSize is not enforced for chunked or unknown-length request bodies #7816 concerns request BODY size and unknown Content-Length. This report concerns how headerMaxSize accounts for request HEADERS.
Current Behavior
Divide's headerMaxSize sums only header VALUE bytes, omitting names and serialized header-field overhead. A header section can exceed the configured rule limit while its values remain below it, and the request is forwarded.
A standalone probe against the current built DividePlugin, actual rule cache and upstream cache produced:
longName=true headerLimit=128 valueBytes=9 headerBytes=225 forwarded=1
longName=false headerLimit=128 valueBytes=209 headerBytes=224 forwarded=0
The first request contains Host: 127.0.0.1 and an empty-valued custom header whose name is X- followed by 200 ASCII N characters. The second uses a short custom header name and a 200-byte value. headerBytes counts HTTP/1.1 field names, : , values, CRLF and the final CRLF; it does not include the request line. The oversized-name case is permitted solely because the implementation examines values.
Expected Behavior
The rule-level headerMaxSize should have a documented size definition and enforce the complete intended header size consistently. If it is intended to mean only header values, that limitation needs to be explicit in configuration/API semantics rather than appearing to be a total request-header limit.
Reproduction
- Configure a divide rule with
headerMaxSize=128, no body restriction, and any valid upstream. - Invoke it with a GET containing the Host field and the long empty-valued header described above.
- Observe that the divide chain forwards the request although its header fields exceed 128 bytes.
- Compare with the same approximate total size using a short name and a long value; this request is rejected by the rule.
The reproduction invoked the actual DividePlugin.doExecute using Spring MockServerWebExchange, a populated DividePluginDataHandler cache, a populated UpstreamCacheManager and a recording downstream chain. It ran outside the deployed gateway process. A complete raw HTTP end-to-end test has not been performed for this report.
Code Evidence
long headerSize = exchange.getRequest().getHeaders().values()
.stream()
.flatMap(Collection::stream)
.mapToLong(header -> header.getBytes(StandardCharsets.UTF_8).length)
.sum();Header names are never read by this calculation. An independent parser/ingress upper bound, such as an 8 KiB Netty limit, does not enforce a smaller rule-specific value of 128 bytes; the example header is well below that outer limit.
Suggested Fix / Coverage
Define the byte-accounting contract and include field names and applicable per-value/header-line overhead. Cover an empty-valued long name, several long names with short values, multi-valued headers, exact-limit and over-limit cases. Keep parser-level protection independent from rule-level policy.
Environment
Apache ShenYu 2.7.2-SNAPSHOT, master 04f7c2e8b7d282f14510157a9ab0bfaab538ecac; Java 17; divide HTTP proxy path. Priority P2 / Medium.
Activity
fix(divide): account for header names and framing in headerMaxSize (a…
fix(divide): account for header names and framing in headerMaxSize (a…
docs(divide): document headerMaxSize behavior change and clarify java…
fix(divide): account for header names and framing in headerMaxSize (a…
docs(divide): document headerMaxSize behavior change and clarify java…
fix(divide): account for header names and framing in headerMaxSize (a…
docs(divide): document headerMaxSize behavior change and clarify java…