listeners. See also the has_ctl() converter used for detecting them.
It is enabled by default on untrusted connections.
+ - reject-duplicate-content-length (inbound request and response)
+ Rejects requests and responses having a duplicate Content-Length header
+ field even if all values perfectly match. While these are tolerated by
+ the standard and is properly sanitized by HAProxy, it can still fool
+ some other reverse-proxies seeing the message before HAProxy and not
+ parsing it correctly. These are still seldom seen in legacy client or
+ server applications, sometimes in relation with compression and/or
+ caching. While HAProxy properly normalizes them, it is generally safe
+ to reject them on public facing listeners. It is enabled by default on
+ untrusted connections.
+
- 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_REJ_CTL_IN_HDR 0x00000400
#define HTTP_HRD_REJ_CL_TE 0x00000800
#define HTTP_HRD_REJ_CL_LEAD_ZERO 0x00001000
+#define HTTP_HRD_REJ_CL_DUP 0x00002000
+
/* insert new masks above this line */
/* update this one with new rejects */
#define HTTP_HRD_ALL_REJECT (HTTP_HRD_REJ_DUP_HOST_HDR | \
HTTP_HRD_REJ_HDR_FOLD | \
HTTP_HRD_REJ_CTL_IN_HDR | \
HTTP_HRD_REJ_CL_TE | \
- HTTP_HRD_REJ_CL_LEAD_ZERO)
+ HTTP_HRD_REJ_CL_LEAD_ZERO | \
+ HTTP_HRD_REJ_CL_DUP)
#define HTTP_HRD_ALL_DELETE (HTTP_HRD_DEL_USCORE_HDR_NAM | \
HTTP_HRD_DEL_USCORE_TLR_NAM | \
HTTP_HRD_DEL_USCORE_HDR_NAM | \
HTTP_HRD_DEL_USCORE_TLR_NAM | \
HTTP_HRD_REJ_CL_TE | \
- HTTP_HRD_REJ_CL_LEAD_ZERO)
+ HTTP_HRD_REJ_CL_LEAD_ZERO | \
+ HTTP_HRD_REJ_CL_DUP)
#define HTTP_HRD_TRUSTED_DEFAULT HTTP_HRD_DEFAULT
expect !~ " on\n"
send "show http-hardening untrusted"
- expect ~ " 1 reject-duplicate-host-header +req +off\n 2 reject-lowercase-method +req +on\n 3 reject-underscore-in-header-name +- +off\n 4 reject-underscore-in-trailer-name +- +off\n 5 delete-underscore-in-header-name +- +on\n 6 delete-underscore-in-trailer-name +- +on\n 7 delete-unregistered-header-fields +- +off\n 8 delete-unregistered-trailer-fields +- +off\n 9 delete-all-trailer-fields +- +off\n10 reject-header-trailer-folding +- +on\n11 reject-ctl-in-header-trailer +- +on\n12 reject-content-length-with-te +- +on\n13 reject-content-length-leading-zero +- +on\n"
+ expect ~ " 1 reject-duplicate-host-header +req +off\n 2 reject-lowercase-method +req +on\n 3 reject-underscore-in-header-name +- +off\n 4 reject-underscore-in-trailer-name +- +off\n 5 delete-underscore-in-header-name +- +on\n 6 delete-underscore-in-trailer-name +- +on\n 7 delete-unregistered-header-fields +- +off\n 8 delete-unregistered-trailer-fields +- +off\n 9 delete-all-trailer-fields +- +off\n10 reject-header-trailer-folding +- +on\n11 reject-ctl-in-header-trailer +- +on\n12 reject-content-length-with-te +- +on\n13 reject-content-length-leading-zero +- +on\n14 reject-duplicate-content-length +- +on\n"
send "show http-hardening other"
expect ~ " 2 reject-lowercase-method +req +off\n(.*\n)*10 reject-header-trailer-folding +- +on\n"
}
/* if duplicate, must be equal */
- if (check_prev && cl != *body_len)
+ if (check_prev && (cl != *body_len || http_harden(HTTP_HRD_REJ_CL_DUP)))
goto fail;
/* OK, store this result as the one to be indexed */
{ "reject-ctl-in-header-trailer", HTTP_HRD_REJ_CTL_IN_HDR, HTTP_DIR_BOTH },
{ "reject-content-length-with-te", HTTP_HRD_REJ_CL_TE, HTTP_DIR_BOTH },
{ "reject-content-length-leading-zero",HTTP_HRD_REJ_CL_LEAD_ZERO, HTTP_DIR_BOTH },
+ { "reject-duplicate-content-length", HTTP_HRD_REJ_CL_DUP, HTTP_DIR_BOTH },
/* 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 },