Merge in SNORT/snort3 from ~ADMAMOLE/snort3:scan_total to master
Squashed commit of the following:
commit
7e8952c3a39590fd7dff1d637b189ded8da70ce9
Author: Adrian Mamolea <admamole@cisco.com>
Date: Wed Jun 22 11:27:53 2022 -0400
http2_inspect: consider continuation when checking headers length
121:38
-HTTP/2 non-Data frame longer than 63780 bytes
+HTTP/2 non-Data frame longer than 63780 bytes. For HEADERS and PUSH_PROMISE frames this includes the
+size of any following continuation frames.
121:39
bool abort_flow[2] = { false, false };
bool processing_partial_header = false;
std::queue<uint32_t> frame_lengths[2];
+ uint32_t accumulated_frame_length[2] = { 0, 0 };
// Internal to reassemble()
uint32_t frame_header_offset[2] = { 0, 0 };
if (session_data->abort_flow[source_id])
return HttpStreamSplitter::status_value(StreamSplitter::ABORT, true);
- const StreamSplitter::Status ret_val =
+ StreamSplitter::Status ret_val =
implement_scan(session_data, data, length, flush_offset, source_id);
session_data->bytes_scanned[source_id] += (ret_val == StreamSplitter::FLUSH)?
*flush_offset : length;
+ if (ret_val == StreamSplitter::SEARCH && session_data->bytes_scanned[source_id] >= MAX_OCTETS)
+ {
+ assert(false);
+ ret_val = StreamSplitter::ABORT;
+ }
+
if (ret_val == StreamSplitter::ABORT)
session_data->abort_flow[source_id] = true;
const uint8_t frame_flags = get_frame_flags(session_data->
scan_frame_header[source_id]);
+ uint32_t& accumulated_frame_length = session_data->accumulated_frame_length[source_id];
+ if ((type == FT_HEADERS || type == FT_PUSH_PROMISE) && !(frame_flags & FLAG_END_HEADERS))
+ accumulated_frame_length = frame_length + FRAME_HEADER_LENGTH;
+
if (type != FT_CONTINUATION)
{
session_data->frame_type[source_id] = type;
*session_data->infractions[source_id] += INF_INVALID_FLAG;
session_data->events[source_id]->create_event(EVENT_INVALID_FLAG);
}
+ accumulated_frame_length += frame_length + FRAME_HEADER_LENGTH;
}
- if ((type != FT_DATA) && (frame_length + FRAME_HEADER_LENGTH > MAX_OCTETS))
+ if (((type == FT_CONTINUATION) && (accumulated_frame_length > MAX_OCTETS)) ||
+ ((type != FT_DATA) && (frame_length + FRAME_HEADER_LENGTH > MAX_OCTETS)))
{
// FIXIT-E long non-data frames may need to be supported
*session_data->infractions[source_id] += INF_NON_DATA_FRAME_TOO_LONG;