From: Victor Julien Date: Tue, 1 Aug 2023 06:44:53 +0000 (+0200) Subject: stream: special handling for RST data X-Git-Tag: suricata-6.0.14~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8cc59df576df103580b0084e8878c460411ddba3;p=thirdparty%2Fsuricata.git stream: special handling for RST data Data on RST packets is not invalid, but also shouldn't be used in reassembly. RFC 1122: 4.2.2.12 RST Segment: RFC-793 Section 3.4 A TCP SHOULD allow a received RST segment to include data. DISCUSSION It has been suggested that a RST segment could contain ASCII text that encoded and explained the cause of the RST. No standard has yet been established for such data. RST data will be presented to the detection engine per packet, but will not be part of stream reassembly. Bug: #6244. (cherry picked from commit b63374bf5f8c85c42056ad3c4cce12bce3d1a6bd) --- diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 6d12443078..9ba06f563f 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -1895,7 +1895,8 @@ int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ } } /* if this segment contains data, insert it */ - if (p->payload_len > 0 && !(stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY)) { + if (p->payload_len > 0 && !(stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY) && + (p->tcph->th_flags & TH_RST) == 0) { SCLogDebug("calling StreamTcpReassembleHandleSegmentHandleData"); if (StreamTcpReassembleHandleSegmentHandleData(tv, ra_ctx, ssn, stream, p) != 0) { @@ -1910,10 +1911,9 @@ int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ p->flags |= PKT_STREAM_ADD; } else { SCLogDebug("ssn %p / stream %p: not calling StreamTcpReassembleHandleSegmentHandleData:" - " p->payload_len %u, STREAMTCP_STREAM_FLAG_NOREASSEMBLY %s", + " p->payload_len %u, STREAMTCP_STREAM_FLAG_NOREASSEMBLY %s", ssn, stream, p->payload_len, (stream->flags & STREAMTCP_STREAM_FLAG_NOREASSEMBLY) ? "true" : "false"); - } /* if the STREAMTCP_STREAM_FLAG_DEPTH_REACHED is set, but not the