From: Shivani Bhardwaj Date: Mon, 19 May 2025 07:13:25 +0000 (+0530) Subject: sip: trigger raw stream inspection X-Git-Tag: suricata-8.0.0-rc1~232 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5583075f5ce44696a466d09f0443a85a9307645;p=thirdparty%2Fsuricata.git sip: trigger raw stream inspection Internals --------- Suricata's stream engine returns data for inspection to the detection engine from the stream when the chunk size is reached. Bug --- Inspection triggered only in the specified chunk sizes may be too late when it comes to inspection of smaller protocol specific data which could result in delayed inspection, incorrect data logged with a transaction and logs misindicating the pkt that triggered an alert. Fix --- Fix this by making an explicit call from all respective applayer parsers to trigger raw stream inspection which shall make the data available for inspection in the following call of the stream engine. This needs to happen per direction on the completion of an entity like a request or a response. Important notes --------------- 1. The above mentioned behavior with and without this patch is affected internally by the following conditions. - inspection depth - stream depth In these special cases, the inspection window will be affected and Suricata may not consider all the data that could be expected to be inspected. 2. This only applies to applayer protocols running over TCP. 3. The inspection window is only considered up to the ACK'd data. 4. This entire issue is about IDS mode only. SIP parser creates a new transaction per request or response. Appropriate calls to trigger raw stream inspection have been added on creation of each request and response. Task 7026 Bug 7004 --- diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index b58940f346..dde0ce5b99 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -19,7 +19,7 @@ use crate::applayer::{self, *}; use crate::core; -use crate::core::{ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP}; +use crate::core::{ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP, sc_app_layer_parser_trigger_raw_stream_inspection}; use crate::direction::Direction; use crate::flow::Flow; use crate::frames::*; @@ -182,6 +182,7 @@ impl SIPState { tx.request_line = req_line; } self.transactions.push_back(tx); + sc_app_layer_parser_trigger_raw_stream_inspection(flow, Direction::ToServer as i32); let consumed = start.len() - rem.len(); start = rem; @@ -277,6 +278,7 @@ impl SIPState { tx.response_line = resp_line; } self.transactions.push_back(tx); + sc_app_layer_parser_trigger_raw_stream_inspection(flow, Direction::ToServer as i32); let consumed = start.len() - rem.len(); start = rem;