Patrick Williams | ab475af | 2022-04-21 14:30:30 -0500 | [diff] [blame^] | 1 | From 6511195c023bf03e0fb19a36f41f42f4edde6e88 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ruslan Ermilov <ru@nginx.com> |
| 3 | Date: Mon, 23 Dec 2019 15:45:46 +0300 |
| 4 | Subject: [PATCH] Discard request body when redirecting to a URL via |
| 5 | error_page. |
| 6 | |
| 7 | Reported by Bert JW Regeer and Francisco Oca Gonzalez. |
| 8 | |
| 9 | Upstream-Status: Backport |
| 10 | CVE: CVE-2019-20372 |
| 11 | |
| 12 | Reference to upstream patch: |
| 13 | https://github.com/nginx/nginx/commit/c1be55f97211d38b69ac0c2027e6812ab8b1b94e |
| 14 | |
| 15 | Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org> |
| 16 | --- |
| 17 | src/http/ngx_http_special_response.c | 6 ++++++ |
| 18 | 1 file changed, 6 insertions(+) |
| 19 | |
| 20 | diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c |
| 21 | index 4ffb2cc8..76e67058 100644 |
| 22 | --- a/src/http/ngx_http_special_response.c |
| 23 | +++ b/src/http/ngx_http_special_response.c |
| 24 | @@ -623,6 +623,12 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page) |
| 25 | return ngx_http_named_location(r, &uri); |
| 26 | } |
| 27 | |
| 28 | + r->expect_tested = 1; |
| 29 | + |
| 30 | + if (ngx_http_discard_request_body(r) != NGX_OK) { |
| 31 | + r->keepalive = 0; |
| 32 | + } |
| 33 | + |
| 34 | location = ngx_list_push(&r->headers_out.headers); |
| 35 | |
| 36 | if (location == NULL) { |
| 37 | -- |
| 38 | 2.17.1 |
| 39 | |