reject-forbidden-payload on
reject-advanced-methods off
reject-unexpected-request-payload off
+ reject-unexpected-request-upgrade off
It is possible to change their settings from the defaults, by declaring the
profiles once, along with the settings to change, in which case they will
static web serving and simple internet-facing applications. It is
disabled by default.
+ - reject-unexpected-request-upgrade (inbound, request)
+ Rejects Upgrade and RFC8441 Extended CONNECT for protocols other than
+ "websocket" and "webtransport". For Upgrade, all offending tokens are
+ removed and the header will be removed if empty, so that it remains
+ harmless to clients sending tentative upgrades. Upgrade and CONNECT are
+ commonly abused to try to establish a tunnel with an application and
+ bypass the reverse-proxy layer, and most applications and browsers do
+ not implement other protocols, so there is no reason for letting them
+ pass through with common web applications. It is generally safe for
+ static web serving and simple internet-facing applications. This is
+ disabled by default. Note that tunnels established via standard CONNECT
+ are NOT blocked with this rule, see 'reject-advanced-methods' for this.
/*
* Local variables:
#define HTTP_HRD_REJ_OOR_STATUS 0x00008000
#define HTTP_HRD_REJ_ADV_METH 0x00010000
#define HTTP_HRD_REJ_UNEXP_REQ_PLD 0x00020000
+#define HTTP_HRD_REJ_UNEXP_REQ_UPG 0x00040000
/* insert new masks above this line */
/* update this one with new rejects */
HTTP_HRD_REJ_FORB_PAYLOAD | \
HTTP_HRD_REJ_OOR_STATUS | \
HTTP_HRD_REJ_ADV_METH | \
- HTTP_HRD_REJ_UNEXP_REQ_PLD)
+ HTTP_HRD_REJ_UNEXP_REQ_PLD | \
+ HTTP_HRD_REJ_UNEXP_REQ_UPG)
#define HTTP_HRD_ALL_DELETE (HTTP_HRD_DEL_USCORE_HDR_NAM | \
HTTP_HRD_DEL_USCORE_TLR_NAM | \
else if ((h1m->flags & H1_MF_CLEAN_CONN_HDR) &&
(isteqi(word, ist("h2c")) || isteqi(word, ist("h2"))))
goto skip_val;
+ else if (!isteqi(word, ist("webtransport"))) {
+ /* neither websocket nor h2c nor n2 nor webtransport,
+ * maybe we have to delete other values.
+ */
+ if (http_harden(HTTP_HRD_REJ_UNEXP_REQ_UPG))
+ goto skip_val;
+ }
if (value->ptr + value->len == p) {
/* no rewrite done till now */
goto fail;
}
+ if (!isteqi(phdr_val[H2_PHDR_IDX_PROT], ist("websocket")) &&
+ !isteqi(phdr_val[H2_PHDR_IDX_PROT], ist("webtransport")) &&
+ http_harden(HTTP_HRD_REJ_UNEXP_REQ_UPG)) {
+ /* neither websocket nor h2c nor n2 nor webtransport,
+ * and hardening enabled => reject.
+ */
+ goto fail;
+ }
+
if (!htx_add_header(htx, ist("upgrade"), phdr_val[H2_PHDR_IDX_PROT]))
goto fail;
if (!htx_add_header(htx, ist("connection"), ist("upgrade")))
{ "reject-out-of-range-status", HTTP_HRD_REJ_OOR_STATUS, HTTP_DIR_RES },
{ "reject-advanced-methods", HTTP_HRD_REJ_ADV_METH, HTTP_DIR_REQ },
{ "reject-unexpected-request-payload", HTTP_HRD_REJ_UNEXP_REQ_PLD, HTTP_DIR_REQ },
+ { "reject-unexpected-request-upgrade", HTTP_HRD_REJ_UNEXP_REQ_UPG, HTTP_DIR_REQ },
/* insert new hardening options above this line */
{ "all-reject", HTTP_HRD_ALL_REJECT, HTTP_DIR_BOTH },
{ "all-delete", HTTP_HRD_ALL_DELETE, HTTP_DIR_BOTH },