Added check to reduce MongoDB false positive detection
This commit is contained in:
@@ -75,9 +75,12 @@ static void ndpi_check_mongodb(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
memcpy(&mongodb_hdr, packet->payload, sizeof(struct mongo_message_header));
|
memcpy(&mongodb_hdr, packet->payload, sizeof(struct mongo_message_header));
|
||||||
|
|
||||||
mongodb_hdr.message_length = ntohs(mongodb_hdr.message_length);
|
/* All MongoDB numbers are in host byte order */
|
||||||
|
// mongodb_hdr.message_length = ntohl(mongodb_hdr.message_length);
|
||||||
|
|
||||||
if (mongodb_hdr.message_length < 4) {
|
if((mongodb_hdr.message_length < 4)
|
||||||
|
|| (mongodb_hdr.message_length > 1000000) /* Used to avoid false positives */
|
||||||
|
) {
|
||||||
NDPI_LOG_DBG(ndpi_struct, "Invalid MONGODB length");
|
NDPI_LOG_DBG(ndpi_struct, "Invalid MONGODB length");
|
||||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||||
return;
|
return;
|
||||||
@@ -127,8 +130,7 @@ void ndpi_search_mongodb(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
|
|
||||||
void init_mongodb_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
void init_mongodb_dissector(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
|
||||||
{
|
|
||||||
ndpi_set_bitmask_protocol_detection("MongoDB", ndpi_struct, detection_bitmask,
|
ndpi_set_bitmask_protocol_detection("MongoDB", ndpi_struct, detection_bitmask,
|
||||||
*id, NDPI_PROTOCOL_MONGODB, ndpi_search_mongodb,
|
*id, NDPI_PROTOCOL_MONGODB, ndpi_search_mongodb,
|
||||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
|
||||||
|
|||||||
Reference in New Issue
Block a user