From: Willy Tarreau Date: Mon, 23 Nov 2026 07:53:30 +0000 (+0100) Subject: MEDIUM: http_ana: control acceptance of 1xx status on HTTP/1.0 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=26f3b4bf32502347d3d0d22c1f3c7f45f3e31633;p=haproxy.git MEDIUM: http_ana: control acceptance of 1xx status on HTTP/1.0 HTTP/1.0 doesn't define status codes 1xx and these ones are not uniformly handled across agents. These must never be emitted, neither by an 1.0 server nor to an 1.0 client, or there is a risk of smuggling. Let's block them by default, and subject them to the "http-1.0-status-1xx" response violation rule. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 0fd15bbe6..408525b8b 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2291,6 +2291,13 @@ acceptable-http-response-violations { [-+][,...] } should only be used between trusted WebSocket endpoints, and the risk is moderate. + - "http-1.0-status-1xx" (response): this controls the acceptance of HTTP + status codes below 200 in responses from or to HTTP/1.0 messages. These + ranges were specified as reserved and are not uniformly implemented + across implementations, and present a risk of smuggling. This should only + be used with confirmed valid endpoints, and the risk is low because + HTTP/1.0-only agents became rare. + By default, for backward compatibility, all violations above are flagged as acceptable, meaning that a proxy having "option accept-unsafe-http-*" will accept them all. It may be a good practice to explicitly reset them to "none" diff --git a/include/haproxy/http-t.h b/include/haproxy/http-t.h index 96946c78f..15f7d4186 100644 --- a/include/haproxy/http-t.h +++ b/include/haproxy/http-t.h @@ -223,6 +223,7 @@ enum http_violation_idx { HTTP_VIO_AUTH_HOST_DIFF, // authority and host field mismatch HTTP_VIO_VERSION_STRING, // unsupported version string HTTP_VIO_WEBSOCKET_KEY, // invalid or missing websocket-key header + HTTP_VIO_1XX_HTTP_1_0, // 1xx in response from or to HTTP/1.0 /* insert new violations above this line */ HTTP_VIO_TOTAL_COUNT = 32, // end marker HTTP_VIO_NONE, // special code for none diff --git a/src/http.c b/src/http.c index bd9e96315..b07851ff8 100644 --- a/src/http.c +++ b/src/http.c @@ -1666,6 +1666,7 @@ const struct http_violation http_violations[] = { { "mismatch-authority-host", HTTP_VIO_AUTH_HOST_DIFF, HTTP_DIR_REQ }, { "invalid-version-string", HTTP_VIO_VERSION_STRING, HTTP_DIR_BOTH }, { "invalid-websocket-key", HTTP_VIO_WEBSOCKET_KEY, HTTP_DIR_BOTH }, + { "http-1.0-status-1xx", HTTP_VIO_1XX_HTTP_1_0, HTTP_DIR_RES }, /* insert new violations above this line */ { "all", HTTP_VIO_ALL, HTTP_DIR_BOTH }, { NULL, 0 } diff --git a/src/http_ana.c b/src/http_ana.c index 0eb4721b6..fb87d5ec4 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1602,29 +1602,41 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit) * response, and we're waiting for the next one. Let's allow this response * to go to the client and wait for the next one. There's an exception for * 101 which is used later in the code to switch protocols. + * + * Anyway, for HTTP/1.0 (client or server), <200 is forbidden. */ - if (txn->status < 200 && - (txn->status == 100 || txn->status >= 102)) { - FLT_STRM_CB(s, flt_http_reset(s, msg)); - htx->first = channel_htx_fwd_headers(rep, htx); - msg->msg_state = HTTP_MSG_RPBEFORE; - msg->flags = 0; - txn->server_status = txn->status = 0; - s->logs.t_data = -1; /* was not a response yet */ - s->scf->flags |= SC_FL_SND_ASAP; /* Send ASAP informational messages */ - goto next_one; - } - - /* A 101-switching-protocols must contains a Connection header with the - * "upgrade" option and the request too. It means both are agree to - * upgrade. It is not so strict because there is no test on the Upgrade - * header content. But it is probably stronger enough for now. - */ - if (txn->status == 101 && - (!(txn->req.flags & HTTP_MSGF_CONN_UPG) || !(txn->rsp.flags & HTTP_MSGF_CONN_UPG))) { - if (objt_server(s->target)) - health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); - goto return_bad_res; + if (unlikely(txn->status < 200)) { + if (!(txn->req.flags & txn->rsp.flags & HTTP_MSGF_VER_11) && + !(s->be->options2 & PR_O2_RSPBUG_OK && + global.acc_hres_vio & (1U << HTTP_VIO_1XX_HTTP_1_0))) { + /* at least one side is not 1.1 compatible, this is a violation */ + if (objt_server(s->target)) + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + goto return_bad_res; + } + + if (txn->status == 100 || txn->status >= 102) { + FLT_STRM_CB(s, flt_http_reset(s, msg)); + htx->first = channel_htx_fwd_headers(rep, htx); + msg->msg_state = HTTP_MSG_RPBEFORE; + msg->flags = 0; + txn->server_status = txn->status = 0; + s->logs.t_data = -1; /* was not a response yet */ + s->scf->flags |= SC_FL_SND_ASAP; /* Send ASAP informational messages */ + goto next_one; + } + + /* A 101-switching-protocols must contains a Connection header with the + * "upgrade" option and the request too. It means both are agree to + * upgrade. It is not so strict because there is no test on the Upgrade + * header content. But it is probably stronger enough for now. + */ + if (txn->status == 101 && + (!(txn->req.flags & HTTP_MSGF_CONN_UPG) || !(txn->rsp.flags & HTTP_MSGF_CONN_UPG))) { + if (objt_server(s->target)) + health_adjust(__objt_server(s->target), HANA_STATUS_HTTP_HDRRSP); + goto return_bad_res; + } } /*