From 3ff82320fff509d63b26412216942fcb9a093a09 Mon Sep 17 00:00:00 2001 From: bui Date: Wed, 4 Dec 2013 19:51:50 +0100 Subject: [PATCH] Added specific internal naxsi rule (id:15) for empty/0 content length POST requests --- naxsi_src/naxsi_runtime.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/naxsi_src/naxsi_runtime.c b/naxsi_src/naxsi_runtime.c index 3c381a44..bc6354d4 100644 --- a/naxsi_src/naxsi_runtime.c +++ b/naxsi_src/naxsi_runtime.c @@ -104,6 +104,14 @@ ngx_http_rule_t nx_int__uncommon_post_boundary = {/*type*/ 0, /*whitelist flag*/ /*block*/ 1, /*allow*/ 0, /*drop*/ 0, /*log*/ 0, /*br ptrs*/ NULL}; +ngx_http_rule_t nx_int__empty_post_body = {/*type*/ 0, /*whitelist flag*/ 0, + /*wl_id ptr*/ NULL, /*rule_id*/ 15, + /*log_msg*/ NULL, /*score*/ 0, + /*sscores*/ NULL, + /*sc_block*/ 1, /*sc_allow*/ 0, + /*block*/ 1, /*allow*/ 0, /*drop*/ 0, /*log*/ 0, + /*br ptrs*/ NULL}; + #define dummy_error_fatal(ctx, r, ...) do { \ @@ -1834,7 +1842,12 @@ ngx_http_dummy_body_parse(ngx_http_request_ctx_t *ctx, ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "XX-BODY PARSE"); #endif - if (!r->request_body->bufs || !r->headers_in.content_type) { + + if (!r->request_body->bufs) { + ngx_http_apply_rulematch_v_n(&nx_int__empty_post_body, ctx, r, NULL, NULL, BODY, 1, 0); + return ; + } + if (!r->headers_in.content_type) { #ifdef dummy_body_parse_debug ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "XX-No content type ..");