Skip to content

Commit

Permalink
Correctly handle bogusly large chunk sizes
Browse files Browse the repository at this point in the history
This fixes a denial of service attack vector where bogusly large chunk
sizes in requests could be used to force restarts of the Varnish
server.

This is Varnish Security Vulnerability VSV00001

For more information visit: https://varnish-cache.org/security/VSV00001

Fixes: varnishcache#2379
  • Loading branch information
mbgrydeland authored and dmatetelki committed Mar 14, 2019
1 parent 999b39b commit 9e03eb9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/varnishd/http1/cache_http1_vfp.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
if (q == NULL || *q != '\0')
return (VFP_Error(vc, "chunked header number syntax"));
cl = (ssize_t)cll;
if ((uintmax_t)cl != cll)
if (cl < 0 || (uintmax_t)cl != cll)
return (VFP_Error(vc, "bogusly large chunk size"));

vfe->priv2 = cl;
Expand Down
40 changes: 40 additions & 0 deletions bin/varnishtest/tests/f00001.vtc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
varnishtest "Check that we handle bogusly large chunks correctly"

# Check that the bug has been fixed

server s1 {
rxreq
txresp
} -start

varnish v1 -vcl+backend {
} -start

client c1 {
send "POST / HTTP/1.1\r\n"
send "Transfer-Encoding: chunked\r\n\r\n"
send "FFFFFFFFFFFFFFED\r\n"
send "0\r\n\r\n"

rxresp
expect resp.status == 503
} -run

# Check that the published workaround does not cause harm

varnish v1 -vcl+backend {
sub vcl_recv {
if (req.http.transfer-encoding ~ "(?i)chunked") {
return (fail);
}
}
}

client c1 {
send "POST / HTTP/1.1\r\n"
send "Transfer-Encoding: chunked\r\n\r\n"
send "FFFFFFFFFFFFFFED\r\n"

rxresp
expect resp.status == 503
} -run

0 comments on commit 9e03eb9

Please sign in to comment.