Skip to content

Commit baef88a

Browse files
defanatorzimmerle
authored andcommitted
Avoid processing of subrequests initiated by the error_page
Closes #164, owasp-modsecurity/ModSecurity#2143.
1 parent 6412273 commit baef88a

4 files changed

+16
-0
lines changed

Diff for: src/ngx_http_modsecurity_header_filter.c

+4
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
420420

421421
/* XXX: if NOT_MODIFIED, do we need to process it at all? see xslt_header_filter() */
422422

423+
if (r->error_page) {
424+
return ngx_http_next_header_filter(r);
425+
}
426+
423427
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity_module);
424428

425429
dd("header filter, recovering ctx: %p", ctx);

Diff for: src/ngx_http_modsecurity_log.c

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ ngx_http_modsecurity_log_handler(ngx_http_request_t *r)
4141
ngx_http_modsecurity_ctx_t *ctx;
4242
ngx_http_modsecurity_conf_t *mcf;
4343

44+
if (r->error_page) {
45+
return NGX_OK;
46+
}
47+
4448
dd("catching a new _log_ phase handler");
4549

4650
mcf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity_module);

Diff for: src/ngx_http_modsecurity_pre_access.c

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)
4848
ngx_http_modsecurity_ctx_t *ctx;
4949
ngx_http_modsecurity_conf_t *mcf;
5050

51+
if (r->error_page) {
52+
return NGX_DECLINED;
53+
}
54+
5155
dd("catching a new _preaccess_ phase handler");
5256

5357
mcf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity_module);

Diff for: src/ngx_http_modsecurity_rewrite.c

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ ngx_http_modsecurity_rewrite_handler(ngx_http_request_t *r)
2727
ngx_http_modsecurity_ctx_t *ctx;
2828
ngx_http_modsecurity_conf_t *mcf;
2929

30+
if (r->error_page) {
31+
return NGX_DECLINED;
32+
}
33+
3034
mcf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity_module);
3135
if (mcf == NULL || mcf->enable != 1) {
3236
dd("ModSecurity not enabled... returning");

0 commit comments

Comments
 (0)