diff --git a/varnish-2.1.5.fix_CVE-2013-4484.patch b/varnish-2.1.5.fix_CVE-2013-4484.patch new file mode 100644 index 0000000..5221c84 --- /dev/null +++ b/varnish-2.1.5.fix_CVE-2013-4484.patch @@ -0,0 +1,101 @@ +diff -Naur ../varnish-2.1.5.orig/bin/varnishd/cache_center.c ./bin/varnishd/cache_center.c +--- ../varnish-2.1.5.orig/bin/varnishd/cache_center.c 2011-01-24 22:30:34.000000000 +0100 ++++ ./bin/varnishd/cache_center.c 2013-11-06 00:25:25.044427816 +0100 +@@ -1125,10 +1125,12 @@ + static int + cnt_start(struct sess *sp) + { +- int done; ++ int err_code; + char *p; +- const char *r = "HTTP/1.1 100 Continue\r\n\r\n"; +- ++ const char *r_100 = "HTTP/1.1 100 Continue\r\n\r\n"; ++ const char *r_400 = "HTTP/1.1 400 Bad Request\r\n\r\n"; ++ const char *r_413 = "HTTP/1.1 413 Request Entity Too Large\r\n\r\n"; ++ const char *r_417 = "HTTP/1.1 417 Expectation Failed\r\n\r\n"; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + AZ(sp->restarts); + AZ(sp->obj); +@@ -1150,10 +1152,14 @@ + sp->wrk->vcl = NULL; + + http_Setup(sp->http, sp->ws); +- done = http_DissectRequest(sp); ++ err_code = http_DissectRequest(sp); + + /* If we could not even parse the request, just close */ +- if (done < 0) { ++ if (err_code == 400) ++ (void)write(sp->fd, r_400, strlen(r_400)); ++ else if (err_code == 413) ++ (void)write(sp->fd, r_413, strlen(r_413)); ++ if (err_code != 0) { + sp->step = STP_DONE; + vca_close_session(sp, "junk"); + return (0); +@@ -1165,12 +1171,6 @@ + /* Catch original request, before modification */ + HTTP_Copy(sp->http0, sp->http); + +- if (done != 0) { +- sp->err_code = done; +- sp->step = STP_ERROR; +- return (0); +- } +- + sp->doclose = http_DoConnection(sp->http); + + /* XXX: Handle TRACE & OPTIONS of Max-Forwards = 0 */ +@@ -1180,13 +1180,14 @@ + */ + if (http_GetHdr(sp->http, H_Expect, &p)) { + if (strcasecmp(p, "100-continue")) { +- sp->err_code = 417; +- sp->step = STP_ERROR; ++ (void)write(sp->fd, r_417, strlen(r_417)); ++ sp->step = STP_DONE; ++ vca_close_session(sp, "junk"); + return (0); + } + + /* XXX: Don't bother with write failures for now */ +- (void)write(sp->fd, r, strlen(r)); ++ (void)write(sp->fd, r_100, strlen(r_100)); + /* XXX: When we do ESI includes, this is not removed + * XXX: because we use http0 as our basis. Believed + * XXX: safe, but potentially confusing. +diff -Naur ../varnish-2.1.5.orig/bin/varnishtest/tests/r01367.vtc ./bin/varnishtest/tests/r01367.vtc +--- ../varnish-2.1.5.orig/bin/varnishtest/tests/r01367.vtc 1970-01-01 01:00:00.000000000 +0100 ++++ ./bin/varnishtest/tests/r01367.vtc 2013-11-06 00:26:12.592576118 +0100 +@@ -0,0 +1,30 @@ ++test "blank GET" ++ ++server s1 { ++ rxreq ++ txresp ++} -start ++ ++varnish v1 -vcl+backend { ++ sub vcl_error { ++ return (restart); ++ } ++} -start ++ ++client c1 { ++ send "GET \nHost: example.com\n\n" ++ rxresp ++ expect resp.status == 400 ++} -run ++ ++client c1 { ++ txreq -hdr "Expect: Santa-Claus" ++ rxresp ++ expect resp.status == 417 ++} -run ++ ++client c1 { ++ txreq ++ rxresp ++ expect resp.status == 200 ++} -run