http-hardening cl0
reject-content-length-leading-zero on
+ http-hardening adv-meth
+ reject-advanced-methods on
+
defaults
mode http
http-reuse never
bind "fd@${req_ctl}" http-hardening ctl
bind "fd@${req_clte}" http-hardening clte
bind "fd@${req_cl0}" http-hardening cl0
+ bind "fd@${req_adv_meth}" http-hardening adv-meth
http-request return status 200 hdr x-meth "%[method]" hdr x-hdrs "%[req.hdr_names]" hdr x-foo "%[req.hdr(foo),hex]"
# response side: one listener per server profile
rxresp
expect resp.status == 200
+ txreq -nouseragent -req TRACE
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "TRACE"
+
+ txreq -nouseragent -req MY-METH
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "MY-METH"
+
# T-E + C-L forces a close
txreq -nouseragent -req POST -nolen -hdr "content-length: 2" -hdr "transfer-encoding: chunked" -body "2\r\nok\r\n0\r\n\r\n"
rxresp
expect_close
} -run
+# only the most common methods are accepted. CONNECT is always rejected since
+# there is no extended CONNECT in HTTP/1.
+client c_req_adv_meth -connect ${h1_req_adv_meth_sock} {
+ txreq -nouseragent -req GET
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req HEAD
+ rxresp -no_obj
+ expect resp.status == 200
+
+ txreq -nouseragent -req POST
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req PUT
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req DELETE
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req OPTIONS
+ rxresp
+ expect resp.status == 200
+
+ txreq -nouseragent -req PATCH
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "PATCH"
+
+ txreq -nouseragent -req QUERY
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "QUERY"
+
+ txreq -nouseragent -req TRACE
+ rxresp
+ expect resp.status == 405
+ expect_close
+} -run
+
+client c_req_adv_meth2 -connect ${h1_req_adv_meth_sock} {
+ txreq -nouseragent -req CONNECT -url "a:443" -nohost -hdr "host: a:443"
+ rxresp
+ expect resp.status == 405
+ expect_close
+} -run
+
+client c_req_adv_meth3 -connect ${h1_req_adv_meth_sock} {
+ txreq -nouseragent -req MY-METH
+ rxresp
+ expect resp.status == 405
+ expect_close
+} -run
+
+# methods which may only differ from the accepted ones by their length
+client c_req_adv_meth4 -connect ${h1_req_adv_meth_sock} {
+ txreq -nouseragent -req PATCHX
+ rxresp
+ expect resp.status == 405
+ expect_close
+} -run
+
+client c_req_adv_meth5 -connect ${h1_req_adv_meth_sock} {
+ txreq -nouseragent -req QUER
+ rxresp
+ expect resp.status == 405
+ expect_close
+} -run
+
#
# Responses
#
http-hardening cl0
reject-content-length-leading-zero on
+ http-hardening adv-meth
+ reject-advanced-methods on
+
defaults
mode http
http-reuse never
bind "fd@${req_unreg}" proto h2 http-hardening unreg
bind "fd@${req_ctl}" proto h2 http-hardening ctl
bind "fd@${req_cl0}" proto h2 http-hardening cl0
+ bind "fd@${req_adv_meth}" proto h2 http-hardening adv-meth
http-request return status 200 hdr x-meth "%[method]" hdr x-hdrs "%[req.hdr_names]" hdr x-foo "%[req.hdr(foo),hex]"
# response side: one listener per server
rxresp
expect resp.status == 200
} -run
+ stream 13 {
+ txreq -req TRACE -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "TRACE"
+ } -run
+ stream 15 {
+ txreq -req MY-METH -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "MY-METH"
+ } -run
} -run
# without :authority, Host is the only source of the authority
} -run
} -run
+# only the most common methods are accepted
+client c_req_adv_meth -connect ${h1_req_adv_meth_sock} {
+ txpri
+ stream 0 {
+ txsettings
+ rxsettings
+ txsettings -ack
+ rxsettings
+ expect settings.ack == true
+ } -run
+
+ stream 1 {
+ txreq -req GET -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "GET"
+ } -run
+ stream 3 {
+ txreq -req POST -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "POST"
+ } -run
+ stream 5 {
+ txreq -req PUT -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "PUT"
+ } -run
+ stream 7 {
+ txreq -req DELETE -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "DELETE"
+ } -run
+ stream 9 {
+ txreq -req OPTIONS -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "OPTIONS"
+ } -run
+ stream 11 {
+ txreq -req PATCH -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "PATCH"
+ } -run
+ stream 13 {
+ txreq -req QUERY -url / -scheme http -hdr ":authority" "a"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.x-meth == "QUERY"
+ } -run
+ stream 15 {
+ txreq -req TRACE -url / -scheme http -hdr ":authority" "a"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 17 {
+ txreq -req MY-METH -url / -scheme http -hdr ":authority" "a"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 19 {
+ txreq -req PATCHX -url / -scheme http -hdr ":authority" "a"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+ stream 21 {
+ txreq -req QUER -url / -scheme http -hdr ":authority" "a"
+ rxrst
+ expect rst.err == PROTOCOL_ERROR
+ } -run
+} -run
+
#
# Responses
#