supported actions and their respective syntaxes are enumerated in section 4.3
"Actions" (look for actions which tick "HTTP Req").
+ Actions used to block requests ("auth", "deny", "reject", "silent-drop" and
+ "tarpit") are reported when their condition may be true because of a
+ pattern matching the path, the URL, the query string or the parameters they
+ convey (e.g. "deny if { path_beg /admin }"), because such rules are easy to
+ bypass. They are summarized in a notice by default, or reported as warnings
+ depending on the global "on-unreliable-rules" setting. Please read section
+ 7.5 "Secure filtering of HTTP requests" to learn how to write reliable rules.
+ When such a rule is only meant as an extra filter, it may be excluded from
+ this report by placing the "no-warn" keyword right before "if" or "unless"
+ (e.g. "http-request deny no-warn if { ... }"). This keyword is only
+ supported by these actions.
+
This directive is only available from named defaults sections, not anonymous
ones. Rules defined in the defaults section are evaluated before ones in the
associated proxy section. To avoid ambiguities, in this case the same
Note that a very similar but independent protocol is under development. See
https://www.ietf.org/archive/id/draft-bt-httpbis-reverse-http-00.html.
-auth [realm <realm>]
+auth [realm <realm>] [no-warn]
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
- | - | - | - | - | X | - | -
message must not be altered, consider to use "http-request return" rule
instead.
+ Except in specific cases, this rule shouldn't be used to intercept access to
+ resources that may be aliased (path, query string etc), as it will not catch
+ all possible forms. See 7.5 "Secure filtering of HTTP requests" for details.
+ If this rule is used in an http-request statement conditionned by an ACL
+ involving inputs that may be subject to aliasing, a warning will be emitted
+ unless the "no-warn" option is placed before the "if" or "unless" keyword.
+
Example:
acl auth_ok http_auth_group(L1) G1
http-request auth unless auth_ok
deny [ { status | deny_status } <code> ] [ content-type <type> ]
[ { default-errorfiles | errorfile <file> | errorfiles <name> |
file <file> | lf-file <file> | string <str> | lf-string <fmt> } ]
- [ hdr <name> <fmt> ]*
+ [ hdr <name> <fmt> ]* [no-warn]
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
- | - | - | - | - | X | X | -
for the current section. See also the "return" action for the advanced
syntax.
+ Except in specific cases, this rule shouldn't be used to intercept access to
+ resources that may be aliased (path, query string etc), as it will not catch
+ all possible forms. See 7.5 "Secure filtering of HTTP requests" for details.
+ If this rule is used in an http-request statement conditionned by an ACL
+ involving inputs that may be subject to aliasing, a warning will be emitted
+ unless the "no-warn" option is placed before the "if" or "unless" keyword.
+
dgram-drop
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
See the "redirect" keyword for the rule's syntax.
-reject
+reject [no-warn]
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
X | X | X | X | X | X | - | -
connection is immediately closed without any SSL handshake processing and the
client is notified via a CONNECTION_REFUSED error code.
+ Except in specific cases, this rule shouldn't be used to intercept access to
+ resources that may be aliased (path, query string etc), as it will not catch
+ all possible forms. See 7.5 "Secure filtering of HTTP requests" for details.
+ If this rule is used in an http-request statement conditionned by an ACL
+ involving inputs that may be subject to aliasing, a warning will be emitted
+ unless the "no-warn" option is placed before the "if" or "unless" keyword.
+
replace-header <name> <match-regex> <replace-fmt>
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
http-request set-vars-from-map(req,/etc/haproxy/limits.map,int)
-silent-drop [ rst-ttl <ttl> ]
+silent-drop [ rst-ttl <ttl> ] [no-warn]
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
- | X | X | X | X | X | X | -
client's. This must not be used unless the consequences of doing this are
fully understood.
+ Except in specific cases, this rule shouldn't be used to intercept access to
+ resources that may be aliased (path, query string etc), as it will not catch
+ all possible forms. See 7.5 "Secure filtering of HTTP requests" for details.
+ If this rule is used in an http-request statement conditionned by an ACL
+ involving inputs that may be subject to aliasing, a warning will be emitted
+ unless the "no-warn" option is placed before the "if" or "unless" keyword.
+
strict-mode { on | off }
Usable in: QUIC Ini| TCP RqCon| RqSes| RqCnt| RsCnt| HTTP Req| Res| Aft
cheaply block known scanners or well-known attack patterns before they reach
the servers. They must just never be the only protection.
+In order to help spot such rules, HAProxy reports them when the condition
+of an "http-request" rule using one of the "auth", "deny", "reject",
+"silent-drop" or "tarpit" actions may be true because of a match on contents
+which support multiple equivalent forms. These are the path, the URL, the
+query string and the parameters they convey, as returned by the "base",
+"base32", "base32+src", "baseq", "capture.req.uri", "path", "pathq", "query",
+"req.body_param", "url", "url32", "url32+src", "url_param", "urlp" and
+"urlp_val" sample fetch functions and their derived ACL keywords, regardless
+of any converter applied to them. Only a term which makes the condition true
+when it matches is considered, i.e. a non-negated term after "if", or a negated
+one after "unless". This means that the allow-lists above are not reported. A
+notice message will indicate affected rules. When such a rule is only meant as
+an extra filter, it may be excluded from this report by placing the "no-warn"
+keyword right before "if" or "unless". It also serves as a reminder for whoever
+modifies the rule later that it is not reliable by itself :
+
+ http-request deny no-warn if { path_sub -i %2e %2f }
+ http-request deny no-warn if { query -m sub -i <script }
+
8. Logging
----------
{
struct act_rule *rule;
const struct action_kw *custom = NULL;
+ int no_warn = 0;
int cur_arg;
rule = new_act_rule(ACT_F_HTTP_REQ, file, linenum);
}
if (*args[cur_arg] && strcmp(args[cur_arg - 1], "no-warn") == 0) {
+ no_warn = 1;
for (cur_arg--; *args[cur_arg + 1]; cur_arg++)
args[cur_arg] = args[cur_arg + 1];
args[cur_arg] = args[cur_arg + 1];
goto out_err;
}
rule->cond = cond;
+
+ if ((custom->flags & KWF_ACCESS_CTRL) && !no_warn) {
+ const struct acl *acl;
+ const char *kw;
+
+ if (acl_cond_find_positive_use(cond, SMP_USE__MAY_ALIAS, &acl, &kw)) {
+ ha_notice("parsing [%s:%d] : 'http-request %s' applies when '%s'%s%s%s matches a pattern,"
+ " which may be bypassed since HTTP allows many equivalent forms of a same request"
+ " (case, %%-encoding, '//', '/./', '/../', '\\', etc). Only rejecting what was not"
+ " explicitly accepted is reliable (e.g. 'http-request %s unless <accepted>')."
+ " If this rule is only an extra filter, add 'no-warn' before '%s' to silence this"
+ " warning. See 'Secure filtering of HTTP requests' in the configuration manual.\n",
+ file, linenum, args[0], kw,
+ *acl->name ? " (from ACL '" : "", acl->name, *acl->name ? "')" : "",
+ args[0], args[cur_arg]);
+ }
+ }
}
else if (*args[cur_arg]) {
ha_alert("parsing [%s:%d]: 'http-request %s' expects"