not to do it on responses however when applications uses such header
fields to report information to HAProxy.
+ - delete-unregistered-trailer-fields (inbound, request and response)
+ Deletes from requests and responses any trailer field whose name starts
+ with 'x-' (upper or lower case). These trailer fields are not
+ registered with IANA and are not used across the internet by standard
+ components. They may appear in untrusted requests in attacks trying to
+ exploit some backend framework weaknesses however, so it is generally
+ safe and even recommended to delete such trailers from inbound internet
+ requests.
+
- reject-duplicate-host-header (inbound request)
Rejects requests containing more than one "Host" header field, even if
valid and identical. This is recommended on untrusted listeners. Note that
#define HTTP_HRD_DEL_USCORE_HDR_NAM 0x00000010
#define HTTP_HRD_DEL_USCORE_TLR_NAM 0x00000020
#define HTTP_HRD_DEL_UNREG_HDR 0x00000040
+#define HTTP_HRD_DEL_UNREG_TLR 0x00000080
/* insert new masks above this line */
#define HTTP_HRD_ALL 0xFFFFFFFF
}
/* we may have to delete unregistered header names (X-) */
- if (unlikely(h1m->state != H1_MSG_TRAILERS && http_harden(HTTP_HRD_DEL_UNREG_HDR))) {
+ if (unlikely((h1m->state != H1_MSG_TRAILERS && http_harden(HTTP_HRD_DEL_UNREG_HDR)) ||
+ (h1m->state == H1_MSG_TRAILERS && http_harden(HTTP_HRD_DEL_UNREG_TLR)))) {
if (n.len > 1 && n.ptr[1] == '-' &&
(n.ptr[0] == 'x' || n.ptr[0] == 'X'))
break;
{ "delete-underscore-in-header-name", HTTP_HRD_DEL_USCORE_HDR_NAM, HTTP_DIR_BOTH },
{ "delete-underscore-in-trailer-name", HTTP_HRD_DEL_USCORE_TLR_NAM, HTTP_DIR_BOTH },
{ "delete-unregistered-header-fields",HTTP_HRD_DEL_UNREG_HDR, HTTP_DIR_BOTH },
+ { "delete-unregistered-trailer-fields",HTTP_HRD_DEL_UNREG_TLR, HTTP_DIR_BOTH },
/* insert new hardening options above this line */
{ "all", HTTP_HRD_ALL, HTTP_DIR_BOTH },
{ NULL, 0 }
continue;
}
+ /* we may have to delete unregistered header names (X-) */
+ if (unlikely(http_harden(HTTP_HRD_DEL_UNREG_TLR))) {
+ if (list[idx].n.len > 1 && list[idx].n.ptr[1] == '-' &&
+ (list[idx].n.ptr[0] == 'x' || list[idx].n.ptr[0] == 'X'))
+ /* skip it, so it won't be added */
+ continue;
+ }
+
/* trim leading/trailing LWS as per RC9113#8.2.1 */
for (v = list[idx].v; v.len; v.len--) {
if (unlikely(HTTP_IS_LWS(*v.ptr)))