@@ -63,6 +63,8 @@ unsigned long int DSOLOCAL msc_pcre_match_limit_recursion = 0;
6363
6464int DSOLOCAL status_engine_state = STATUS_ENGINE_DISABLED ;
6565
66+ int DSOLOCAL conn_limits_filter_state = 0 ;
67+
6668unsigned long int DSOLOCAL conn_read_state_limit = 0 ;
6769TreeRoot DSOLOCAL * conn_read_state_whitelist = 0 ;
6870TreeRoot DSOLOCAL * conn_read_state_suspicious_list = 0 ;
@@ -1419,27 +1421,28 @@ static int hook_connection_early(conn_rec *conn)
14191421 }
14201422 }
14211423
1422-
14231424 if (conn_read_state_limit > 0 && ip_count_r > conn_read_state_limit )
14241425 {
14251426 if (conn_read_state_suspicious_list &&
14261427 (tree_contains_ip (conn -> pool ,
14271428 conn_read_state_suspicious_list , client_ip , NULL , & error_msg ) <= 0 ))
14281429 {
1429- ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1430- "ModSecurity: Too many threads [%ld] of %ld allowed in " \
1431- "READ state from %s - There is a suspission list but " \
1432- "that IP is not part of it, access granted" , ip_count_r ,
1433- conn_read_state_limit , client_ip );
1430+ if (conn_limits_filter_state == MODSEC_DETECTION_ONLY )
1431+ ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1432+ "ModSecurity: Too many threads [%ld] of %ld allowed " \
1433+ "in READ state from %s - There is a suspission list " \
1434+ "but that IP is not part of it, access granted" ,
1435+ ip_count_r , conn_read_state_limit , client_ip );
14341436 }
1435-
14361437 else if (tree_contains_ip (conn -> pool ,
14371438 conn_read_state_whitelist , client_ip , NULL , & error_msg ) > 0 )
14381439 {
1439- ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1440- "ModSecurity: Too many threads [%ld] of %ld allowed in " \
1441- "READ state from %s - Ip is on whitelist, access granted" ,
1442- ip_count_r , conn_read_state_limit , client_ip );
1440+ if (conn_limits_filter_state == MODSEC_DETECTION_ONLY )
1441+ ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1442+ "ModSecurity: Too many threads [%ld] of %ld allowed " \
1443+ "in READ state from %s - Ip is on whitelist, access " \
1444+ "granted" , ip_count_r , conn_read_state_limit ,
1445+ client_ip );
14431446 }
14441447 else
14451448 {
@@ -1448,7 +1451,9 @@ static int hook_connection_early(conn_rec *conn)
14481451 "threads [%ld] of %ld allowed in READ state from %s - " \
14491452 "Possible DoS Consumption Attack [Rejected]" , ip_count_r ,
14501453 conn_read_state_limit , client_ip );
1451- return OK ;
1454+
1455+ if (conn_limits_filter_state == MODSEC_ENABLED )
1456+ return OK ;
14521457 }
14531458 }
14541459
@@ -1458,19 +1463,22 @@ static int hook_connection_early(conn_rec *conn)
14581463 (tree_contains_ip (conn -> pool ,
14591464 conn_write_state_suspicious_list , client_ip , NULL , & error_msg ) <= 0 ))
14601465 {
1461- ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1462- "ModSecurity: Too many threads [%ld] of %ld allowed in " \
1463- "WRITE state from %s - There is a suspission list but " \
1464- "that IP is not part of it, access granted" , ip_count_w ,
1465- conn_read_state_limit , client_ip );
1466+ if (conn_limits_filter_state == MODSEC_DETECTION_ONLY )
1467+ ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1468+ "ModSecurity: Too many threads [%ld] of %ld allowed " \
1469+ "in WRITE state from %s - There is a suspission list " \
1470+ "but that IP is not part of it, access granted" ,
1471+ ip_count_w , conn_read_state_limit , client_ip );
14661472 }
14671473 else if (tree_contains_ip (conn -> pool ,
14681474 conn_write_state_whitelist , client_ip , NULL , & error_msg ) > 0 )
14691475 {
1470- ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1471- "ModSecurity: Too many threads [%ld] of %ld allowed in " \
1472- "WRITE state from %s - Ip is on whitelist, access granted" ,
1473- ip_count_w , conn_read_state_limit , client_ip );
1476+ if (conn_limits_filter_state == MODSEC_DETECTION_ONLY )
1477+ ap_log_error (APLOG_MARK , APLOG_WARNING , 0 , NULL ,
1478+ "ModSecurity: Too many threads [%ld] of %ld allowed " \
1479+ "in WRITE state from %s - Ip is on whitelist, " \
1480+ "access granted" , ip_count_w , conn_read_state_limit ,
1481+ client_ip );
14741482 }
14751483 else
14761484 {
@@ -1479,7 +1487,9 @@ static int hook_connection_early(conn_rec *conn)
14791487 "threads [%ld] of %ld allowed in WRITE state from %s - " \
14801488 "Possible DoS Consumption Attack [Rejected]" , ip_count_w ,
14811489 conn_write_state_limit , client_ip );
1482- return OK ;
1490+
1491+ if (!conn_limits_filter_state == MODSEC_ENABLED )
1492+ return OK ;
14831493 }
14841494 }
14851495 }
0 commit comments