access-control policy for example. No standard HTTP header uses this,
so it is safe to enable on untrusted listeners.
+ - reject-underscore-in-trailer-name (inbound, request and response)
+ Rejects requests and responses in which one tailer field name contains
+ an underscore character ('_' or \x5C). This character is perfectly
+ permitted, but some application frameworks which create automatic
+ variables tend to already turn the dash ('-') into an underscore in
+ variable names, leading to an ambiguity with the underscore which can
+ result in the same variable name. No standard HTTP trailer uses this,
+ so it is safe to enable on untrusted listeners.
+
/*
* Local variables:
* fill-column: 79
#define HTTP_HRD_REJ_DUP_HOST_HDR 0x00000001
#define HTTP_HRD_REJ_LCASE_METHOD 0x00000002
#define HTTP_HRD_REJ_USCORE_HDR_NAM 0x00000004
+#define HTTP_HRD_REJ_USCORE_TLR_NAM 0x00000008
/* insert new masks above this line */
#define HTTP_HRD_ALL 0xFFFFFFFF
if (isupper((unsigned char)*ptr) && h1m->flags & H1_MF_TOLOWER)
*ptr = tolower((unsigned char)*ptr);
else if (unlikely(*ptr == '_')) {
- if ((h1m->state != H1_MSG_TRAILERS && http_harden(HTTP_HRD_REJ_USCORE_HDR_NAM))) {
+ if ((h1m->state != H1_MSG_TRAILERS && http_harden(HTTP_HRD_REJ_USCORE_HDR_NAM)) ||
+ (h1m->state == H1_MSG_TRAILERS && http_harden(HTTP_HRD_REJ_USCORE_TLR_NAM))) {
state = H1_MSG_RQMETH;
goto http_msg_invalid;
}
{ "reject-duplicate-host-header", HTTP_HRD_REJ_DUP_HOST_HDR, HTTP_DIR_REQ },
{ "reject-lowercase-method", HTTP_HRD_REJ_LCASE_METHOD, HTTP_DIR_REQ },
{ "reject-underscore-in-header-name", HTTP_HRD_REJ_USCORE_HDR_NAM, HTTP_DIR_BOTH },
+ { "reject-underscore-in-trailer-name", HTTP_HRD_REJ_USCORE_TLR_NAM, HTTP_DIR_BOTH },
/* insert new hardening options above this line */
{ "all", HTTP_HRD_ALL, HTTP_DIR_BOTH },
{ NULL, 0 }
ret = HTTP_PRS_INV_HNAME;
goto fail;
}
+
+ if (list[idx].n.ptr[i] == '_' &&
+ http_harden(HTTP_HRD_REJ_USCORE_TLR_NAM)) {
+ ret = HTTP_PRS_INV_HNAME;
+ goto fail;
+ }
}
/* All field names affecting decoding or routing are forbidden