Skip to content

Commit

Permalink
http2_hpack: Enforce http_req_hdr_len limit
Browse files Browse the repository at this point in the history
Refs #3709
  • Loading branch information
Dridi committed Mar 29, 2024
1 parent cdcae28 commit a90f542
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/varnishd/http2/cache_http2_hpack.c
Expand Up @@ -161,7 +161,7 @@ h2h_addhdr(struct http *hp, struct h2h_decode *d)
disallow_empty = 0;
has_dup = 0;

if (Tlen(hdr) > UINT_MAX) { /* XXX: cache_param max header size */
if (Tlen(hdr) > cache_param->http_req_hdr_len) {
VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.20s", hdr.b);
return (H2SE_ENHANCE_YOUR_CALM);
}
Expand Down
21 changes: 21 additions & 0 deletions bin/varnishtest/tests/r03709.vtc
@@ -0,0 +1,21 @@
varnishtest "h2 req limits"

varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.set http_req_hdr_len 40b"
varnish v1 -vcl {
backend be none;
} -start

logexpect l1 -v v1 -g raw -q BogoHeader {
expect 0 1001 BogoHeader "Header too large: :path"
} -start

client c1 {
stream next {
txreq -url ${string,repeat,4,/123456789}
rxrst
expect rst.err == ENHANCE_YOUR_CALM
} -run
} -run

logexpect l1 -wait

0 comments on commit a90f542

Please sign in to comment.