safe and even recommended to delete such trailers from inbound internet
requests.
+ - reject-content-length-leading-zero (inbound request and response)
+ Rejects requests and responses having a Content-Length header field
+ whose value contains a leading zero before a digit. Some client and
+ server applications tend to parse this as an octal value giving a
+ different body size (e.g. "0300" = 192). This can be used in attacks
+ trying to desynchronize a client or server from the rest of the
+ communication, and for example for cache poisionning attacks. These may
+ seldom be seen on legacy applications but not on standard components
+ found on the internet, so it is generally safe to reject them on public
+ facing listeners.
+
- reject-content-length-with-te (inbound request and response)
Rejects requests and responses having both a Content-Length header
field and a Transfer-Encoding header field. While these are permitted
#define HTTP_HRD_REJ_HDR_FOLD 0x00000200
#define HTTP_HRD_REJ_CTL_IN_HDR 0x00000400
#define HTTP_HRD_REJ_CL_TE 0x00000800
+#define HTTP_HRD_REJ_CL_LEAD_ZERO 0x00001000
/* insert new masks above this line */
#define HTTP_HRD_ALL 0xFFFFFFFF
if (unlikely(!cl && n > word.ptr)) {
/* There was a leading zero before this digit,
* let's trim it.
+ * In strict mode we reject it though.
*/
+ if (http_harden(HTTP_HRD_REJ_CL_LEAD_ZERO))
+ goto fail;
word.ptr = n;
}
{ "reject-header-trailer-folding", HTTP_HRD_REJ_HDR_FOLD, HTTP_DIR_BOTH },
{ "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 },
/* insert new hardening options above this line */
{ "all", HTTP_HRD_ALL, HTTP_DIR_BOTH },
{ NULL, 0 }