so it is recommended to enable on untrusted listeners. Note that this
applies only after "reject-underscore-in-header-name" was accepted.
+ - delete-underscore-in-trailer-name (inbound, request and response)
+ Deletes from requests and responses any trailer field whose name
+ contains an underscore character ('_' or \x5C). While this character is
+ perfectly permitted, some application frameworks which create automatic
+ variables 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
+ recommended to enable on untrusted listeners. Note that this applies
+ only after "reject-underscore-in-trailer-name" was accepted.
+
- 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
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.
+ so it is safe to enable on untrusted listeners. See also the
+ "delete-underscore-in-trailer-name" variant.
/*
* Local variables:
#define HTTP_HRD_REJ_USCORE_HDR_NAM 0x00000004
#define HTTP_HRD_REJ_USCORE_TLR_NAM 0x00000008
#define HTTP_HRD_DEL_USCORE_HDR_NAM 0x00000010
+#define HTTP_HRD_DEL_USCORE_TLR_NAM 0x00000020
/* insert new masks above this line */
#define HTTP_HRD_ALL 0xFFFFFFFF
*/
if (unlikely(http_hdng_chk.found & HTTP_HRD_REJ_USCORE_HDR_NAM) &&
((h1m->state != H1_MSG_TRAILERS && istlen(istfind(n, '_')) &&
- http_harden(HTTP_HRD_DEL_USCORE_HDR_NAM)))) {
+ http_harden(HTTP_HRD_DEL_USCORE_HDR_NAM)) ||
+ (h1m->state == H1_MSG_TRAILERS && istlen(istfind(n, '_')) &&
+ http_harden(HTTP_HRD_DEL_USCORE_TLR_NAM)))) {
/* skip it, so it won't be added */
break;
}
{ "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 },
{ "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 },
/* insert new hardening options above this line */
{ "all", HTTP_HRD_ALL, HTTP_DIR_BOTH },
{ NULL, 0 }
goto fail;
}
+ /* we may have to delete trailers with underscores
+ * in their names. These ones are already marked
+ * as found when not rejected so we can avoid a
+ * costly lookup in normal times.
+ */
+ if (unlikely(http_hdng_chk.found & HTTP_HRD_REJ_USCORE_TLR_NAM) &&
+ istlen(istfind(list[idx].n, '_')) && http_harden(HTTP_HRD_DEL_USCORE_TLR_NAM)) {
+ /* 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)))