expressed relative to the traffic received or sent by that side, and never in
terms of requests or responses.
-http-hardening <name> [from <name2>]
+http-hardening <name> [from <source>]
Declares a new hardening profile <name>. A profile can only be declared once.
- The name "auto" is reserved. When "from" is used, the profile starts with the
- settings of the already declared profile <name2>, otherwise it starts with
- the defaults. A profile must be declared before being referenced by a "bind"
- or "server" line or by "from", like for "defaults" sections.
-
- The profiles "untrusted" and "trusted" always exist even if never declared.
- They may be declared once to change their settings, in which case they start
- from their defaults. They are supported in "from" to create new profiles. The
- reserved name "auto" may not be defined nor used in "from".
+ The name "auto" is reserved and may neither be defined nor referenced as a
+ source in "from". When "from" is used, the profile starts with the settings
+ of the already existing profile <source>, otherwise it starts with the
+ defaults. A profile must be declared before being referenced by a "bind" or
+ "server" line or by "from", like for "defaults" sections.
+
+ The profiles "untrusted" and "trusted" always exist and are preset to their
+ respective default values so that they don't need to be declared for most
+ common use cases. Their default settings (the list of on/off controls) may be
+ displayed at boot time by passing "-dHharden" on the command line, and should
+ reflect the following values:
+
+ http-hardening trusted
+ all off
+
+ http-hardening untrusted
+ reject-duplicate-host-header off
+ reject-lowercase-method on
+ reject-underscore-in-header-name off
+ reject-underscore-in-trailer-name off
+ delete-underscore-in-header-name on
+ delete-underscore-in-trailer-name on
+ delete-unregistered-header-fields off
+ delete-unregistered-trailer-fields off
+ delete-all-trailer-fields off
+ reject-header-trailer-folding on
+ reject-ctl-in-header-trailer on
+ reject-content-length-with-te on
+ reject-content-length-leading-zero on
+ reject-duplicate-content-length on
+ reject-forbidden-payload on
+ reject-out-of-range-status on
+
+ It is possible to change their settings from the defaults, by declaring the
+ profiles once, along with the settings to change, in which case they will
+ inherit from their defaults first. They may even be declared with a "from"
+ keyword to ignore their defaults and start from another profile instead,
+ including one of them. For example, in order to simply apply all "untrusted"
+ settings to the "trusted" profile, just do this:
+
+ http-hardening trusted from untrusted
+
+ Like other profiles, they are supported as sources in "from" to create new
+ profiles. All enabled hardening profiles' settings may be consulted at run
+ time using "show http-hardening" on the CLI.
<keyword> { on | off }
Enables or disables the hardening check designated by <keyword> in the
getaddrinfo() exist on various systems and cause anomalies that are
difficult to troubleshoot.
+ -dH[<class>[,...]] : dump HTTP specific settings. It can be used to dump HTTP
+ hardening profiles using "-dHharden", all HTTP information using "-dHall",
+ or help about other HTTP specific information using "-dHhelp".
+
-dI : enable the insecure fork. This is the equivalent of the
"insecure-fork-wanted" in the global section. It can be useful when running
all the reg-tests with ASAN which need to fork addr2line to resolve the
struct ist http_trim_leading_spht(struct ist value);
struct ist http_trim_trailing_spht(struct ist value);
+void http_dump_settings(const char *what);
/*
* Given a path string and its length, find the position of beginning of the
#if defined(USE_CPU_AFFINITY)
" -dc dumps the list of selected and evicted CPUs\n"
#endif
+ " -dH{class[,...]} dump HTTP settings\n"
" -dK{class[,...]} dump registered keywords (use 'help' for list)\n"
" -dr ignores server address resolution failures\n"
" -dV disables SSL verify on servers side\n"
}
# endif /* HA_HAVE_DL_ITERATE_PHDR */
#endif
+ else if (*flag == 'd' && flag[1] == 'H') {
+ http_dump_settings(flag + 2);
+ }
else if (*flag == 'd' && flag[1] == 'K') {
arg_mode |= MODE_DUMP_KWD;
kwd_dump = flag + 2;
}
+/* dump various HTTP settings to stdout, used by -dH on the cmdline. Supports
+ * a comma-delimited list of classes, dumps everything by default.
+ */
+void http_dump_settings(const char *what)
+{
+ const char *end;
+ int all = 0;
+
+ if (!*what) {
+ /* empty: dump everything */
+ what = "*";
+ all = 1;
+ }
+
+ for (; what && *what; what = end) {
+ end = strchr(what, ',');
+ if (!end)
+ end = what + strlen(what);
+
+ if (strncmp(what, "help", end - what) == 0) {
+ printf("# List of supported HTTP classes:\n");
+ printf("harden: list all hardening profiles\n");
+ continue;
+ }
+ else if (strncmp(what, "all", end - what) == 0) {
+ all = 1;
+ }
+
+ if (all || strncmp(what, "harden", end - what) == 0) {
+ const struct http_hardening_kw *kw;
+ int len, max;
+
+ printf("# List of HTTP hardening profiles, and default settings:\n");
+
+ len = max = 0;
+ for (kw = http_hardening_kws; kw->name; kw++) {
+ len = strlen(kw->name);
+ max = len > max ? len : max;
+ }
+ max += 2;
+
+ printf("http-hardening trusted\n");
+ if (!HTTP_HRD_TRUSTED_DEFAULT)
+ printf("\tall off\n");
+ else for (kw = http_hardening_kws; kw->name; kw++) {
+ // only report single bit flags
+ if (!(kw->mask & (kw->mask - 1)))
+ printf("\t%-*s %s\n", max, kw->name, (kw->mask & HTTP_HRD_TRUSTED_DEFAULT) ? "on" : "off");
+ }
+
+ printf("\nhttp-hardening untrusted\n");
+ if (!HTTP_HRD_UNTRUSTED_DEFAULT)
+ printf("\tall off\n");
+ else for (kw = http_hardening_kws; kw->name; kw++) {
+ // only report single bit flags
+ if (!(kw->mask & (kw->mask - 1)))
+ printf("\t%-*s %s\n", max, kw->name, (kw->mask & HTTP_HRD_UNTRUSTED_DEFAULT) ? "on" : "off");
+ }
+ }
+ }
+}
+
static struct cfg_kw_list cfg_kws = {{ },{
{ CFG_GLOBAL, "http-err-codes", http_parse_http_err_fail_codes },
{ CFG_GLOBAL, "http-fail-codes", http_parse_http_err_fail_codes },