Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit ff86ca7

Browse files
committed
For HTTP/1.1 requests, Host is mandatory
The check is added to the builtin logic for now. Fixes #2631.
1 parent acaa2d4 commit ff86ca7

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

bin/varnishd/builtin.vcl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,14 @@ vcl 4.0;
3636

3737
sub vcl_recv {
3838
if (req.method == "PRI") {
39-
/* This will never happen in properly formed traffic (see: RFC7540) */
40-
return (synth(405));
39+
/* This will never happen in properly formed traffic (see: RFC7540) */
40+
return (synth(405));
41+
}
42+
if (!req.http.host &&
43+
req.esi_level == 0 &&
44+
req.proto ~ "^(?i)HTTP/1.1") {
45+
/* In HTTP/1.1, Host is required. */
46+
return (synth(400));
4147
}
4248
if (req.method != "GET" &&
4349
req.method != "HEAD" &&

bin/varnishtest/tests/r02633.vtc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
varnishtest "For HTTP/1.1 requests, Host is mandatory"
2+
3+
server s1 {
4+
rxreq
5+
txresp
6+
} -start
7+
8+
varnish v1 -vcl+backend {
9+
} -start
10+
11+
client c1 {
12+
txreq -proto HTTP/1.1
13+
rxresp
14+
expect resp.status == 200
15+
txreq -proto HTTP/1.1 -nohost
16+
rxresp
17+
expect resp.status == 400
18+
txreq -proto HTTP/1.0 -nohost
19+
rxresp
20+
expect resp.status == 200
21+
} -run

0 commit comments

Comments
 (0)