@@ -63,6 +63,8 @@ unsigned long int DSOLOCAL msc_pcre_match_limit_recursion = 0;
63
63
64
64
int DSOLOCAL status_engine_state = STATUS_ENGINE_DISABLED ;
65
65
66
+ int DSOLOCAL conn_limits_filter_state = 0 ;
67
+
66
68
unsigned long int DSOLOCAL conn_read_state_limit = 0 ;
67
69
TreeRoot DSOLOCAL * conn_read_state_whitelist = 0 ;
68
70
TreeRoot DSOLOCAL * conn_read_state_suspicious_list = 0 ;
@@ -1419,27 +1421,28 @@ static int hook_connection_early(conn_rec *conn)
1419
1421
}
1420
1422
}
1421
1423
1422
-
1423
1424
if (conn_read_state_limit > 0 && ip_count_r > conn_read_state_limit )
1424
1425
{
1425
1426
if (conn_read_state_suspicious_list &&
1426
1427
(tree_contains_ip (conn -> pool ,
1427
1428
conn_read_state_suspicious_list , client_ip , NULL , & error_msg ) <= 0 ))
1428
1429
{
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 );
1434
1436
}
1435
-
1436
1437
else if (tree_contains_ip (conn -> pool ,
1437
1438
conn_read_state_whitelist , client_ip , NULL , & error_msg ) > 0 )
1438
1439
{
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 );
1443
1446
}
1444
1447
else
1445
1448
{
@@ -1448,7 +1451,9 @@ static int hook_connection_early(conn_rec *conn)
1448
1451
"threads [%ld] of %ld allowed in READ state from %s - " \
1449
1452
"Possible DoS Consumption Attack [Rejected]" , ip_count_r ,
1450
1453
conn_read_state_limit , client_ip );
1451
- return OK ;
1454
+
1455
+ if (conn_limits_filter_state == MODSEC_ENABLED )
1456
+ return OK ;
1452
1457
}
1453
1458
}
1454
1459
@@ -1458,19 +1463,22 @@ static int hook_connection_early(conn_rec *conn)
1458
1463
(tree_contains_ip (conn -> pool ,
1459
1464
conn_write_state_suspicious_list , client_ip , NULL , & error_msg ) <= 0 ))
1460
1465
{
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 );
1466
1472
}
1467
1473
else if (tree_contains_ip (conn -> pool ,
1468
1474
conn_write_state_whitelist , client_ip , NULL , & error_msg ) > 0 )
1469
1475
{
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 );
1474
1482
}
1475
1483
else
1476
1484
{
@@ -1479,7 +1487,9 @@ static int hook_connection_early(conn_rec *conn)
1479
1487
"threads [%ld] of %ld allowed in WRITE state from %s - " \
1480
1488
"Possible DoS Consumption Attack [Rejected]" , ip_count_w ,
1481
1489
conn_write_state_limit , client_ip );
1482
- return OK ;
1490
+
1491
+ if (!conn_limits_filter_state == MODSEC_ENABLED )
1492
+ return OK ;
1483
1493
}
1484
1494
}
1485
1495
}
0 commit comments