even if not rejected, duplicate host header fields are folded into a
single one.
+ - reject-header-trailer-folding (inbound request and response)
+ Rejects requests and responses which contain folded header fields or
+ trailer fields. Folding consists in having a single field span multiple
+ lines. This practice is obsoleted by modern HTTP standards, absolutely
+ not seen anymore in valid messages over the internet but might still be
+ present in a few antique internal services dealing with large cookies.
+ On untrusted networks, they are always associated with attacks trying
+ to inject headers into non-compliant components, and should be rejected
+ as a sign of break-in attempt. Note that HAProxy does not have problems
+ with them and systematically unfolds these messages before forwarding
+ them.
+
- reject-lowercase-method (inbound request)
Rejects requests whose method contains a lower-case character. No
standard HTTP method uses lower-case characters and these ones are
#define HTTP_HRD_DEL_UNREG_HDR 0x00000040
#define HTTP_HRD_DEL_UNREG_TLR 0x00000080
#define HTTP_HRD_DEL_ALL_TLR 0x00000100
+#define HTTP_HRD_REJ_HDR_FOLD 0x00000200
/* insert new masks above this line */
#define HTTP_HRD_ALL 0xFFFFFFFF
case H1_MSG_HDR_L1_LWS:
http_msg_hdr_l1_lws:
if (likely(HTTP_IS_SPHT(*ptr))) {
+ /* OBS-fold: either reject header folding or transform CR/LF to LWS */
+ if (http_harden(HTTP_HRD_REJ_HDR_FOLD)) {
+ state = H1_MSG_HDR_L1_LWS;
+ goto http_msg_invalid;
+ }
if (!skip_update) {
/* replace HT,CR,LF with spaces */
for (; start + sov < ptr; sov++)
case H1_MSG_HDR_L2_LWS:
http_msg_hdr_l2_lws:
if (unlikely(HTTP_IS_SPHT(*ptr))) {
+ /* OBS-fold: either reject header folding or transform CR/LF to LWS */
+ if (http_harden(HTTP_HRD_REJ_HDR_FOLD)) {
+ state = H1_MSG_HDR_L2_LWS;
+ goto http_msg_invalid;
+ }
if (!skip_update) {
/* LWS: replace HT,CR,LF with spaces */
for (; start + eol < ptr; eol++)
{ "delete-unregistered-header-fields",HTTP_HRD_DEL_UNREG_HDR, HTTP_DIR_BOTH },
{ "delete-unregistered-trailer-fields",HTTP_HRD_DEL_UNREG_TLR, HTTP_DIR_BOTH },
{ "delete-all-trailer-fields", HTTP_HRD_DEL_ALL_TLR, HTTP_DIR_BOTH },
+ { "reject-header-trailer-folding", HTTP_HRD_REJ_HDR_FOLD, HTTP_DIR_BOTH },
/* insert new hardening options above this line */
{ "all", HTTP_HRD_ALL, HTTP_DIR_BOTH },
{ NULL, 0 }