]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
2 years agoflow/manager: fix coverity divide_by_zero warning
Juliana Fajardini [Fri, 24 Mar 2023 20:04:57 +0000 (17:04 -0300)] 
flow/manager: fix coverity divide_by_zero warning

Updated all cases where flow_config.prealloc was used in a division.

*** CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
/src/flow-manager.c: 858 in FlowManager()
852                                "flow_spare_q status: %" PRIu32 "%% flows at the queue",
853                             spare_pool_len, flow_config.prealloc,
854                             spare_pool_len * 100 / flow_config.prealloc);
855
856                     /* only if we have pruned this "emergency_recovery" percentage
857                      * of flows, we will unset the emergency bit */
>>>     CID 1524506:  Integer handling issues  (DIVIDE_BY_ZERO)
>>>     In expression "spare_pool_len * 100U / flow_config.prealloc", division by expression "flow_config.prealloc" which may be zero has undefined behavior.
858                     if (spare_pool_len * 100 / flow_config.prealloc > flow_config.emergency_recovery) {
859                         emerg_over_cnt++;
860                     } else {
861                         emerg_over_cnt = 0;
862                     }

Related to
Bug #5919

(cherry picked from commit 754d2803dd5f5956b7f2ae947f933ef03cf1d15b)

2 years agoflow/manager: fix prealloc unhandled division by 0
Juliana Fajardini [Mon, 20 Mar 2023 14:56:58 +0000 (11:56 -0300)] 
flow/manager: fix prealloc unhandled division by 0

If flow.prealloc was set to zero in our yaml config, this led to
a floating point exception in the flow manager.

Bug: #5919.
(cherry picked from commit 5baa6c0024c7e49eb28e84546c286a5fd50fe303)

2 years agorfb: remove duplicate logging of depth 8636/head
Jason Ish [Wed, 25 Jan 2023 17:07:19 +0000 (11:07 -0600)] 
rfb: remove duplicate logging of depth

The "depth" field in the "pixel_format" object was being logged twice.

Issue: 5813

(cherry picked from commit f15f092a696ebcafb3f402c511ba24be98557e7f)

2 years agosmb: remove duplicate tree_id logging
Jason Ish [Wed, 25 Jan 2023 18:02:27 +0000 (12:02 -0600)] 
smb: remove duplicate tree_id logging

Remove the second occurrence of tree_id logging which appears to
always be a duplicate of the first tree_id logged, even though they
come from different data structures.

Issue: 5811

(cherry picked from commit 67baab573b8046ace275e6c0f671f62af22a49a6)

2 years agodns: remove unused events field from state
Philippe Antoine [Wed, 8 Jun 2022 12:31:24 +0000 (14:31 +0200)] 
dns: remove unused events field from state

found overflowing by oss-fuzz

(cherry picked from commit 26dc70648c2b840ae7b56c88162f129c06ef03fd)

2 years agoutil/mime: use uint8_t for cnt
Shivani Bhardwaj [Wed, 15 Mar 2023 06:26:18 +0000 (11:56 +0530)] 
util/mime: use uint8_t for cnt

cnt should not exceed B64_BLOCK which is 4, so, it is unnecessary to use
uint32_t for the variable.

2 years agoutil/mime: use uint32_t for consumed bytes
Shivani Bhardwaj [Wed, 8 Mar 2023 15:46:03 +0000 (21:16 +0530)] 
util/mime: use uint32_t for consumed bytes

In a case of the line buffer being over 255 bytes, the consumed bytes
would reset to 0 as it was uint8_t. Fix this integer overflow by setting
the type to uint32_t.

Redmine ticket: 5883

(cherry picked from commit c089bbb7d7a6250fc4fdcffca1923a29916c1e1e)

2 years agosmb: handles records with trailing nbss data
Philippe Antoine [Wed, 18 Jan 2023 15:47:56 +0000 (16:47 +0100)] 
smb: handles records with trailing nbss data

If a file (read/write) SMB record has padding/trailing data
after the buffer being read or written, and that Suricata falls
in one case where it skips the data, it should skip until
the very end of the NBSS record, meaning it should also skip the
padding/trailing data.

Otherwise, an attacker may smuggle some NBSS/SMB record in this
trailing data, that will be interpreted by Suricata, but not
by the SMB client/server, leading to evasions.

Ticket: #5786
(cherry picked from commit 233ab1114873e632014b58d91c351505417fe8ed)

2 years agosmb: checks against nbss records length
Philippe Antoine [Tue, 27 Dec 2022 16:34:47 +0000 (17:34 +0100)] 
smb: checks against nbss records length

When Suricata handles files over SMB, it does not wait for the
NBSS record to be complete, and can stream the payload to the
file... But it did not check the consistency of the SMB record
length being read or written against the NBSS record length.

This could lead to an evasion where an attacker crafts a SMB
write with a too big Length field, and then sends its evil
payload, even if the server returned an error for the write request.

Ticket: #5770
(cherry picked from commit c1b7befb18a974eae05b25fad91d9ba84a65ab50)

2 years agonetmap/config: New API display during debug
Jeff Lucovsky [Fri, 24 Feb 2023 15:04:51 +0000 (10:04 -0500)] 
netmap/config: New API display during debug

This PR changes the log level associated with the message indicating
if the new Netmap API (v14+) is in use during module registration.

Issue: 5879

2 years agonetmap: packet stall
Bill Meeks [Thu, 23 Feb 2023 16:12:56 +0000 (11:12 -0500)] 
netmap: packet stall

- Fix packet processing stall under high load when using netmap in IPS mode.
- Detect and generate Fatal Error exit for rare case when hardware NIC exposes
unmatched RX/TX queue counts. This is rare, but would result in some traffic
bypassing Suricata since it assumes NIC queue counts are symmetrical.
- Fix instance of missing unlock call for netmap device list when exiting due
to an error condition.
- Clean up existing code comments and add additional ones to better document
the new netmap v14 API code.

2 years agoconfig: put version in configuration as a proper value
Jason Ish [Mon, 30 Jan 2023 23:13:04 +0000 (17:13 -0600)] 
config: put version in configuration as a proper value

Adds a new field, "suricata-version" to the configuration file with
the major and minor version of the Suricata that generated the
configuration file.

This may be useful in the future for presenting warnings about
important changes, or even providing different defaults based on what
the user might expect.

Ticket: 5822

(cherry picked from commit c6c781ef677132d579b82e7860c83f9dbb2c7301)

2 years agoeve/drop: don't log drops unless packet is dropped
Victor Julien [Tue, 21 Mar 2023 19:20:48 +0000 (20:20 +0100)] 
eve/drop: don't log drops unless packet is dropped

In pass/drop combinations where the pass rule took precendence over
the drop, a "drop" false positive could still be logged due to the
storing of the drop record in the packet drop alert store.

Bug: #5867.
(cherry picked from commit 09348564f032ad61811d2a77aecc1d0472f4a656)

2 years agodetect/urilen: fix applying urilen as depth
Victor Julien [Thu, 23 Mar 2023 14:42:18 +0000 (15:42 +0100)] 
detect/urilen: fix applying urilen as depth

If urilen induced depth was set, later DetectContentPropagateLimits()
would apply a wrong depth setting, leading to a false negative in
some cases.

Bug: #5929.
(cherry picked from commit ba7db2583b0d96627d3088dd3d89b69ad21ff757)

2 years agostream: SYN queue support 8569/head
Victor Julien [Thu, 9 Feb 2023 16:11:21 +0000 (17:11 +0100)] 
stream: SYN queue support

Support case where there are multiple SYN retransmits, where
each has a new timestamp.

Before this patch, Suricata would only accept a SYN/ACK that
matches the last timestamp. However, observed behavior is that
the server may choose to only respond to the first. In IPS mode
this could lead to a connection timing out as Suricata drops
the SYN/ACK it considers wrong, and the server continues to
retransmit it.

This patch reuses the SYN/ACK queuing logic to keep a list
of SYN packets and their window, timestamp, wscale and sackok
settings. Then when the SYN/ACK arrives, it is first evaluated
against the normal session state. But if it fails due to a
timestamp mismatch, it will look for queued SYN's and see if
any of them match the timestamp. If one does, the ssn is updated
to use that SYN and the SYN/ACK is accepted.

Bug: #5856.
(cherry picked from commit 7bfee147ef6caefe0dd4444a088f451188108e0a)

2 years agostream: move state queue code into util func
Victor Julien [Thu, 9 Feb 2023 15:35:53 +0000 (16:35 +0100)] 
stream: move state queue code into util func

(cherry picked from commit 288086af3feb40318784b5fa1e92d73c11081481)

2 years agodebug: add bool string print helper macro
Victor Julien [Wed, 7 Sep 2022 06:38:07 +0000 (08:38 +0200)] 
debug: add bool string print helper macro

(cherry picked from commit 0ec136621d7c5e24b38e706856c461fd5a96ef2d)

2 years agostream: support SYN/ACK with TFO only ack'ing ISN 8568/head
Victor Julien [Sat, 25 Feb 2023 09:10:29 +0000 (10:10 +0100)] 
stream: support SYN/ACK with TFO only ack'ing ISN

Not ack'ing the data.

(cherry picked from commit 7ef57cc7cbbfe6ca0aff3c3526614c7ab6d14d40)

2 years agostream: add liberal timetamps option
Victor Julien [Wed, 22 Feb 2023 14:17:53 +0000 (15:17 +0100)] 
stream: add liberal timetamps option

Linux is slightly more permissive wrt timestamps than many
other OS'. To avoid many events/issues with linux hosts, add an
option to allow for this slightly more permissive behavior.

Ideally the host-os config would be used, but in practice this
setting is rarely set up correctly, if at all.

This option is enabled by default.

(cherry picked from commit 01b7ccc224f573ca2106731b07ea845b27f89661)

2 years agostream: D-SACK detection and logging
Victor Julien [Tue, 21 Feb 2023 09:47:13 +0000 (10:47 +0100)] 
stream: D-SACK detection and logging

RFC 2883 specifies a special use of SACKs to indicate a host has
received a segment it considers a spurious retransmission.

(cherry picked from commit d79a926085ce66e0be4bb22ede1671928b6995fb)

2 years agostream: fix next_seq updates after temporary gap
Victor Julien [Sat, 18 Feb 2023 14:36:55 +0000 (15:36 +0100)] 
stream: fix next_seq updates after temporary gap

On every accepted packet in established state, update next_seq if
packet seq+len is larger than existing next_seq. This allows it to
catch up after large gaps that are filled again a bit later.

Bug: #5877.
(cherry picked from commit 76225bf9ac87ed4312d44b83d9499794cc760207)

2 years agostream: improve first FIN next_seq update
Victor Julien [Tue, 14 Feb 2023 14:36:56 +0000 (15:36 +0100)] 
stream: improve first FIN next_seq update

For accepted FIN packets, always update next_seq. This helps track the
FIN sequence.

Bug: #5877.
(cherry picked from commit 551fb80150c6b07183771e455a30f38953298fff)

2 years agostream: improve FIN next_seq handling
Victor Julien [Wed, 15 Feb 2023 10:56:47 +0000 (11:56 +0100)] 
stream: improve FIN next_seq handling

Update next_seq to SEQ + payload_len + 1, so retransmission checks
work better.

Bug: #5877.
(cherry picked from commit 80a012a7877cad8b9f8d12ba4bab63971ac7bb78)

2 years agostream: set next_seq before last_ack
Victor Julien [Wed, 15 Feb 2023 10:56:01 +0000 (11:56 +0100)] 
stream: set next_seq before last_ack

next_seq sometimes depends on last_ack in cases of packet loss
catch up, so first update it.

Bug: #5877.
(cherry picked from commit 20df715e64ccab00c6f6778e1453b051aee7be17)

2 years agostream/tcp: update ack handling logic
Eric Leblond [Fri, 28 May 2021 10:19:19 +0000 (12:19 +0200)] 
stream/tcp: update ack handling logic

Only update the ack value of a session for regular packets when
the ACK bit is set.

(cherry picked from commit 0d81173d6e912f4be9e3e8f7593d779d8ffed52f)

2 years agostream/tcp: fix wrong ACK trigger FIN1 to FIN2
Victor Julien [Sat, 11 Feb 2023 12:14:53 +0000 (13:14 +0100)] 
stream/tcp: fix wrong ACK trigger FIN1 to FIN2

An ACK that ACK'd older data while still being in-window could
lead to FIN_WAIT1 to FIN_WAIT2 state transition. Detect this
case and generally harden the check.

Bug: #5877.
(cherry picked from commit 67af94f2e07352807cfedb722ea8c79e156da5fc)

2 years agostream: fix overlap detection
Victor Julien [Tue, 28 Feb 2023 10:41:59 +0000 (11:41 +0100)] 
stream: fix overlap detection

If a in-tree segment was partly before base_seq the overlap detection
miscalculated the data offset. This lead to memcmp comparing the wrong
data.

Bug: #5881.

(cherry picked from commit cbcd70537a2af1d15474d08412d3a7134163ee6b)

2 years agostream: set event on bad timestamp on syn_sent state 8531/head 8634/head
Victor Julien [Thu, 9 Feb 2023 08:36:56 +0000 (09:36 +0100)] 
stream: set event on bad timestamp on syn_sent state

(cherry picked from commit fc376f81455ebfd487a0de2f8a14884be073b8ac)

2 years agostream/tcp: allow tcp session reuse on null sessions 8525/head
Victor Julien [Thu, 2 Feb 2023 13:45:30 +0000 (14:45 +0100)] 
stream/tcp: allow tcp session reuse on null sessions

When a "stream starter" packet finds an existing TCP flow, the flow will be
evaluated for reuse.

The following scenario wasn't handled well:

1. Suricata starts after a tool has just stopped using lots of connections
   (e.g. ab stress testing a webserver)
2. even though the client is closed already, the server is still doing
   connection cleanup sending many FINs and later RSTs
3. Suricata creates flows for these packets, but no TCP sessions
4. client resumes testing, creating flows that have the same 5 tuple as the
   flows created for the FIN/RST packets
5. Suricata refuses to "reuse" the flows as the condition "tcp flow w/o session"
   is not considered valid for session reuse
6. new TCP connection is not properly tracked and evaluated in parsing and
   detection

There may be other vectors into this, like a flow w/o session because of
memcap issues.

Bug: #5843.
(cherry picked from commit 93c9594dd8158a9d8fa76fdbc7c02e82da2b0ed2)

2 years agoflowworker: don't keep unnecessary flow reference
Victor Julien [Fri, 27 Jan 2023 19:30:20 +0000 (20:30 +0100)] 
flowworker: don't keep unnecessary flow reference

Flow stream/detect/log flush packets, don't hold on to the flow
beyond the flow worker module.

(cherry picked from commit a2dc9a40e76ded08e084f1c11eff2140380e73ec)

2 years agoversion: start development towards 6.0.11
Victor Julien [Tue, 31 Jan 2023 18:43:17 +0000 (19:43 +0100)] 
version: start development towards 6.0.11

2 years agorelease: 6.0.10; update changelog suricata-6.0.10
Shivani Bhardwaj [Tue, 31 Jan 2023 06:18:36 +0000 (11:48 +0530)] 
release: 6.0.10; update changelog

2 years agorequirements: suricata-update 1.2.7 8500/head
Jason Ish [Mon, 30 Jan 2023 18:02:47 +0000 (12:02 -0600)] 
requirements: suricata-update 1.2.7

2 years agothreshold: suppress debug notice message 8499/head
Victor Julien [Mon, 30 Jan 2023 15:08:24 +0000 (16:08 +0100)] 
threshold: suppress debug notice message

2 years agodecode/events: add strict mode for udp.hlen_invalid; remove rule
Victor Julien [Mon, 30 Jan 2023 12:55:52 +0000 (13:55 +0100)] 
decode/events: add strict mode for udp.hlen_invalid; remove rule

2 years agorules/decoder: add udp.len_invalid rule
Shivani Bhardwaj [Wed, 18 Jan 2023 01:35:08 +0000 (07:05 +0530)] 
rules/decoder: add udp.len_invalid rule

(cherry picked from commit b5b05b8fce68ac18e7ea6330508afc3ad0c35866)

2 years agodecode/udp: fix payload_len calculation
Shivani Bhardwaj [Wed, 4 Jan 2023 06:30:13 +0000 (12:00 +0530)] 
decode/udp: fix payload_len calculation

Fix payload_len calculation post removal of the condition that returned
error code if the length to the decode fn did not match the length of
header from the UDP packet.

Bug 5379

(cherry picked from commit f941ceae2be883596a3571ec9046ea884d3f3f85)

2 years agodecode/events: add event type UDP_LEN_INVALID
Shivani Bhardwaj [Wed, 18 Jan 2023 00:53:13 +0000 (06:23 +0530)] 
decode/events: add event type UDP_LEN_INVALID

(cherry picked from commit eebdfe9a3e46be0508ff636db0fc514a4f922656)

2 years agodecode-udp: Allow shorter UDP packets than the remaining payload length
Lukas Sismis [Fri, 27 Jan 2023 11:34:37 +0000 (12:34 +0100)] 
decode-udp: Allow shorter UDP packets than the remaining payload length

If the packet is shorter than IP payload length we no longer flag it as an
invalid UDP packet. UDP packet can be therefore shorter than IP payload.
Keyword "udp.hlen_invalid" became outdated as we no longer flag short UDP
packets as invalid. The keyword's evaluation remains the same.

Inspired by commit: d18e52ed93e996bc0335d4a100b2ac7f12b3848d

Redmine ticket: #5793

2 years agofuzz: checks pcap timestamp consistency
Philippe Antoine [Mon, 30 Jan 2023 09:49:29 +0000 (10:49 +0100)] 
fuzz: checks pcap timestamp consistency

Inspired by commit e22b59b8c17c2fb8ae30b2612086a7975cd94a6c

Master7 is now diverging with use of SCTime_t

2 years agoapp-layer: explicitly enable sip, rdp and mqtt
Victor Julien [Mon, 30 Jan 2023 12:42:31 +0000 (13:42 +0100)] 
app-layer: explicitly enable sip, rdp and mqtt

In the default config these were enabled implicitly, as their `enabled`
field was commented out. This lead to warnings in the default config.

Ticket: #5299.

2 years agodetect: config keyword transaction logic fix 8458/head
Philippe Antoine [Mon, 25 Jul 2022 08:33:42 +0000 (10:33 +0200)] 
detect: config keyword transaction logic fix

When the keyword config:logging disable,type tx is used,
OutputTxLog checks a flag to skip the transaction without logging
it, but AppLayerParserTransactionsCleanup waits for the
transaction to be marked as logged to clean it.

So, OutputTxLog now marks the tx as logged, so that it can
get cleaned away.

Ticket: #5456
(cherry picked from commit 0c0fcc94111b183ae2953f659d14ab2f671fc019)

2 years agosmb: set defaults for file transfer limits
Victor Julien [Tue, 24 Jan 2023 11:38:21 +0000 (12:38 +0100)] 
smb: set defaults for file transfer limits

Ticket: #5782.
(cherry picked from commit 37f13a4fc7356432cfec80852eb1f58da7cc8850)

2 years agostream/tcp: fix typos, update copyright year 8454/head
Juliana Fajardini [Thu, 19 Jan 2023 14:21:10 +0000 (11:21 -0300)] 
stream/tcp: fix typos, update copyright year

Bug #5765

2 years agoexceptions: ignore policy if stream.midstream=true
Juliana Fajardini [Thu, 19 Jan 2023 14:18:16 +0000 (11:18 -0300)] 
exceptions: ignore policy if stream.midstream=true

Set the engine to ignore the stream.midstream-policy if stream.midstream
is enabled.

If we had both stream.midstream AND stream.midstream_policy enabled,
this could lead to midstream flows being dropped (or bypassed, or...)
instead of being accepted by the engine, as it was probably meant when
the user enabled midstream flows.

Bug #5765

(cherry picked from commit 8e9905e0d833858a5053285c8ffe6ed4ed30fc12)

2 years agonfs2: improve READ parsing
Philippe Antoine [Wed, 25 Jan 2023 15:20:00 +0000 (16:20 +0100)] 
nfs2: improve READ parsing

Inspired by commit ddf14e51dcf5dabdb4bc07414a118530e2a1b819

But keeping old nom version

2 years agofuzz: specify protocol with fuzz target name
Philippe Antoine [Mon, 29 Mar 2021 18:27:34 +0000 (20:27 +0200)] 
fuzz: specify protocol with fuzz target name

cf https://redmine.openinfosecfoundation.org/issues/4125

This allows fuzz_applayerparser_parse to fuzz one specific
app-layer protocol based on the binary name, as is done
with the environment variable FUZZ_APPLAYER
That is if we rename/copy to fuzz_applayerparser_parse_smb,
it will fuzz only SMB protocol
This way, we can easily produce different fuzz targets for
each protocol in oss-fuzz

(cherry picked from commit e9b76a0e663ce5c2f8900f90a4f4fd7ed3436335)

2 years agonetmap: Fixup issues with v14+ backport
Jeff Lucovsky [Fri, 20 Jan 2023 14:16:05 +0000 (09:16 -0500)] 
netmap: Fixup issues with v14+ backport

This commit reduces the changes associated with adding the v14 api to
6.0.x

During the preparation of this commit, issues in the original backport
were corrected
- Failure to release a lock under error conditions
- Typo in an CPP ifdef
- Incorrect target for goto statement in an error handling case.

Issue: 5744

2 years agotest: do not output non ascii character
Philippe Antoine [Thu, 15 Sep 2022 13:26:46 +0000 (15:26 +0200)] 
test: do not output non ascii character

The unit test for content |aa bz| transforms in place the string
str to replace the 2 characters aa by one character 0xaa
Then, when z is not recognized as a valid hexadeicmal character,
the whole modified string is printed out, inclusing the non-ascii
0xaa

Ticket: #5558
(cherry picked from commit b281199e9aa1d2d66ac35d1f53358afca8c44a13)

2 years agosmb/ntlmssp: parse fields independently of order
Philippe Antoine [Tue, 6 Dec 2022 13:34:37 +0000 (14:34 +0100)] 
smb/ntlmssp: parse fields independently of order

Instead of relying on the usual ordering...

Ticket: #5258
(cherry picked from commit 1db86858482ddfed446f2f124c546a133e01b17c)

Manual conflict fixes to use nom instead of nom7

2 years agodoc/userguide: ubuntu: install software-properties-common 8428/head
Jason Ish [Tue, 29 Nov 2022 20:32:03 +0000 (14:32 -0600)] 
doc/userguide: ubuntu: install software-properties-common

This package likely needs to be installed when starting with an Ubuntu
container or other minimal Ubuntu install.

Ticket: #5616
(cherry picked from commit 0a4e3d0f82a5bf9d6090b3663b143a689bd52d9e)

2 years agosmb: fix post-trunc chunk behavior
Victor Julien [Wed, 11 Jan 2023 20:07:16 +0000 (21:07 +0100)] 
smb: fix post-trunc chunk behavior

After a gap in a file transaction, the file tracker is truncated. However
this did not clear any stored out of order chunks from memory or stop more
chunks to be stored, leading to accumulation of a large number of chunks.

This patches fixes this be clearing the stored chunks on trunc. It also
makes sure no more chunks are stored in the tracker after the trunc.

Bug: #5781.
(cherry picked from commit a24d7dc45c818054f97448ce42ca9ba270b3b8e4)

2 years agostreaming/sbb: fix debug message
Victor Julien [Thu, 5 Jan 2023 06:25:26 +0000 (07:25 +0100)] 
streaming/sbb: fix debug message

(cherry picked from commit 989e5c7ba23534a488794592193deea8c3a293e8)

2 years agostream: remove bug on from packet path
Victor Julien [Wed, 4 Jan 2023 19:39:24 +0000 (20:39 +0100)] 
stream: remove bug on from packet path

(cherry picked from commit a00db15bd41ad08bec19ad3c252d1aab92c5c525)

2 years agosrc: fix deprecated-non-prototype compile warnings
Victor Julien [Tue, 17 Jan 2023 10:10:54 +0000 (11:10 +0100)] 
src: fix deprecated-non-prototype compile warnings

Tested on Fedora 37 with clang 15.

util-strlcatu.c:45:8: error: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
size_t strlcat(dst, src, siz)
           ^
1 error generated.

(cherry picked from commit 41ca206fdfa1a071d5bf18ae2a18e1e4cea583bd)

2 years agosrc: fix unused-but-set-variable compile warnings
Victor Julien [Mon, 16 Jan 2023 21:09:02 +0000 (22:09 +0100)] 
src: fix unused-but-set-variable compile warnings

Tested on Fedora 37 with clang 15.

datasets.c:852:9: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
    int n = 0;
        ^
1 error generated.

(cherry picked from commit 1bc6976a061a78f953f6b9c796cd4135c1494beb)

2 years agosrc: fix strict-prototype warnings
Victor Julien [Mon, 16 Jan 2023 18:14:28 +0000 (19:14 +0100)] 
src: fix strict-prototype warnings

Tested on Fedora 37 with clang 15.

app-layer.c:1055:27: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
void AppLayerSetupCounters()
                          ^
                           void
app-layer.c:1176:29: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
void AppLayerDeSetupCounters()
                            ^
                             void
2 errors generated.

(cherry picked from commit ebd87282196e4757db44e9d40823477b34484238)

2 years agouserguide: update http2 config header syntax
jason taylor [Wed, 11 Jan 2023 18:38:53 +0000 (18:38 +0000)] 
userguide: update http2 config header syntax

Signed-off-by: jason taylor <jtfas90@gmail.com>
2 years agoftp: completely resets port_line
Philippe Antoine [Wed, 28 Dec 2022 14:57:12 +0000 (15:57 +0100)] 
ftp: completely resets port_line

In the case port_line is first allocated and port_line_len is set,
Then a second request reaches memcap and frees port_line,
port_line_len should also be reset, because both will get used
by the response parsing.

Ticket: #5701
(cherry picked from commit 1660172a8b5af48b156096c4ad8bebcd9dbfafd9)

2 years agodcerpc: store consumed_bytes as i32 8419/head
Philippe Antoine [Sat, 2 Apr 2022 19:16:53 +0000 (21:16 +0200)] 
dcerpc: store consumed_bytes as i32

As it can grow bigger than u16

(cherry picked from commit 704bc878ea3f2fcb911d38b6a21aa5a7ee4d2a79)

2 years agorust: fix for loop over option 8376/head
Jason Ish [Fri, 13 Jan 2023 20:04:52 +0000 (14:04 -0600)] 
rust: fix for loop over option

As of Rust 1.66 with strict mode enabled, a for loop over an option is
now an error. Replace the last occurrence of this pattern with an "if
let" statement.

2 years agotls: fix off by one in supported versions extension 8374/head
Philippe Antoine [Fri, 11 Nov 2022 10:52:27 +0000 (11:52 +0100)] 
tls: fix off by one in supported versions extension

Ticket: #5663
(cherry picked from commit b5147189aecd1d49520e6dc9b40b1baca5a4f503)

2 years agossl: add debug validation checks for recent changes
Victor Julien [Tue, 1 Nov 2022 15:48:13 +0000 (16:48 +0100)] 
ssl: add debug validation checks for recent changes

Make sure the assumptions are correct.

(cherry picked from commit 8f0d820218585ea450fd87b86e8754f03805cb38)

2 years agotls: fix buffer overread
Philippe Antoine [Wed, 5 Oct 2022 19:21:41 +0000 (21:21 +0200)] 
tls: fix buffer overread

Recently introduced by commit 4bab6e24e5e2cef29c9a5a6bee3263e4a3d47e76

Ticket: #5564
(cherry picked from commit 3fbcba8ab7c042fd6f802cdeae02cb0c67771c7a)

2 years agossl: fix compiler warning
Philippe Antoine [Tue, 27 Sep 2022 13:47:06 +0000 (15:47 +0200)] 
ssl: fix compiler warning

implicit conversion loses integer precision: 'int' to 'uint16_t'
because C shifts << translates automatically to signed integers

(cherry picked from commit ae6abd8ca3eb0e3157eb8709d97c9432beb9e373)

2 years agotls: handle incomplete header sooner
Victor Julien [Wed, 21 Sep 2022 17:56:45 +0000 (19:56 +0200)] 
tls: handle incomplete header sooner

Make sure to exit the parser early on incomplete header data.

Additionally, make sure to not create duplicated tls frames in this
case.

Add a debug validation check for the header parser parsing too much
data, which should never happen.

(cherry picked from commit 1701a6b14c0fef6a374368a31c8a0d753b574b9c)

2 years agossl: add debug validation check for incomplete api
Victor Julien [Wed, 7 Sep 2022 18:51:18 +0000 (20:51 +0200)] 
ssl: add debug validation check for incomplete api

(cherry picked from commit 9053c49178ac9746e9f36534c1ffce05dad205c8)

2 years agotls: improve record checks
Victor Julien [Wed, 7 Sep 2022 06:32:05 +0000 (08:32 +0200)] 
tls: improve record checks

Improve unknown record handling. Inspired by Wireshark 'unknown record'
handling, we take a best effort approach for records with unknown content
types in TLS versions 1.0, 1.1 and 1.2.

Improve record length check and set 'invalid_record_length' event instead
of 'invalid_tls_header'.

(cherry picked from commit 69be41b241bc7fd1a5b7f3988b51f5859ab27d57)

2 years agotls: improve versions extension logic
Victor Julien [Wed, 7 Sep 2022 05:31:38 +0000 (07:31 +0200)] 
tls: improve versions extension logic

Skip over unusable versions like GREASE.

(cherry picked from commit c028800ae151415ca524ede755f9b880a19771ab)

2 years agotls: make version and size checks stricter
Victor Julien [Tue, 6 Sep 2022 12:03:46 +0000 (14:03 +0200)] 
tls: make version and size checks stricter

This way bad records won't buffer lots of stream data.

(cherry picked from commit 599791fa33cf5a3be51d7cdd857350f53bb68fc2)

2 years agotls: store cert data in heap buffer
Victor Julien [Mon, 29 Aug 2022 07:25:26 +0000 (09:25 +0200)] 
tls: store cert data in heap buffer

Cert chain is a list of pointers into this buffer, so can't use a
stream slice approach.

(cherry picked from commit c73d8120261c2470e49c25f7249c2ad8599e8fa1)

2 years agotls: prepare for client cert parsing
Victor Julien [Tue, 23 Aug 2022 09:31:08 +0000 (11:31 +0200)] 
tls: prepare for client cert parsing

(cherry picked from commit 10f5e6cb66a3fd8faa735eeddd307ef3b3f2bba4)

2 years agotls: make cert handling more generic
Victor Julien [Tue, 23 Aug 2022 05:19:38 +0000 (07:19 +0200)] 
tls: make cert handling more generic

In preparation for client cert handling.

(cherry picked from commit 14b2e04b58dbebf274290b0cbe9e40571c8941ef)

2 years agotls: avoid tls.invalid_handshake_message FP
Victor Julien [Mon, 22 Aug 2022 08:49:34 +0000 (10:49 +0200)] 
tls: avoid tls.invalid_handshake_message FP

Don't set TLS_DECODER_EVENT_INVALID_HANDSHAKE_MESSAGE event on encrypted
handshake messages.

(cherry picked from commit cf4c201acbf6e9558e450a8dc76d12b48bf49b8d)

2 years agotls: don't set 2 events for a single exception
Victor Julien [Thu, 11 Aug 2022 10:18:28 +0000 (12:18 +0200)] 
tls: don't set 2 events for a single exception

Keep the more specific ones.

(cherry picked from commit e9d63f335542b45123796f42801de730a63e6432)

2 years agotls: remove incomplete tests
Victor Julien [Thu, 11 Aug 2022 13:25:11 +0000 (15:25 +0200)] 
tls: remove incomplete tests

These tests are incompatible with the incomplete API usage and should
have been pcap based tests in the first place.

(cherry picked from commit 214e466b29b941e8805ac1531089607f9dae06b5)

2 years agotls: set event if record size exceeds limit
Victor Julien [Mon, 8 Aug 2022 10:02:22 +0000 (12:02 +0200)] 
tls: set event if record size exceeds limit

(cherry picked from commit 82e03bd8fc721cf47964460f261500b10433ea14)

2 years agotls: support server hello done message
Victor Julien [Wed, 10 Aug 2022 15:44:44 +0000 (17:44 +0200)] 
tls: support server hello done message

(cherry picked from commit e857c864ca1cb0af6a01f2b14c172bf83c78f0d3)

2 years agotls: support handshake fragmentation
Victor Julien [Fri, 5 Aug 2022 20:27:22 +0000 (22:27 +0200)] 
tls: support handshake fragmentation

Implement TLS record defrag for handshake messages.

Ticket: #5183.
(cherry picked from commit 4bab6e24e5e2cef29c9a5a6bee3263e4a3d47e76)

2 years agotls: remove certificate buffering code
Victor Julien [Fri, 5 Aug 2022 12:39:57 +0000 (14:39 +0200)] 
tls: remove certificate buffering code

TCP Buffering is now done in the app-layer using the incomplete API, on
the SSL/TLS record level. TLS level fragmentation will be implemented
separately.

(cherry picked from commit bcaf0f6f7db83aa5941346b0eaf81fa5765e0576)

2 years agotls: parse handshake protocol records in single pass
Victor Julien [Mon, 8 Aug 2022 10:23:37 +0000 (12:23 +0200)] 
tls: parse handshake protocol records in single pass

(cherry picked from commit 0839317ea7ebfcd28e7cac2ef516696ba42693c9)

2 years agosslv2: use version from client hello
Victor Julien [Wed, 7 Sep 2022 05:37:46 +0000 (07:37 +0200)] 
sslv2: use version from client hello

Remove streaming code that is now unused.

Incomplete handling makes this record parsing work on full data.

(cherry picked from commit 9f0ea5e70c3e557d25118e59aa5fc1b32aeca976)

2 years agossl: implement 'incomplete' handling for SSLv2
Victor Julien [Thu, 18 Aug 2022 08:51:35 +0000 (10:51 +0200)] 
ssl: implement 'incomplete' handling for SSLv2

(cherry picked from commit c8d79fb81fef91fef27d28ad06ee4136e8e282b6)

2 years agotls: streaming mode for application records
Victor Julien [Wed, 7 Sep 2022 07:43:19 +0000 (09:43 +0200)] 
tls: streaming mode for application records

To avoid overhead of stream buffering for records we don't do
much with anyway, pass through application records instead of
buffering the entire record in the stream engine.

(cherry picked from commit 6076a5151127f039932cb99d771259c18762c59a)

2 years agotls: use incomplete API to get full TLS records
Victor Julien [Fri, 5 Aug 2022 10:03:37 +0000 (12:03 +0200)] 
tls: use incomplete API to get full TLS records

The TLS record header is parsed in streaming mode still, but once the
record size is known we tell the app-layer API to give us the full
record.

Ticket: #5481

(cherry picked from commit 129fcb5c7232fd9c8245958f7fb7d2d9ebe9d8ce)

2 years agodetect/tls: Improve tls.fingerprint rule handling
Jeff Lucovsky [Sun, 11 Sep 2022 14:00:53 +0000 (10:00 -0400)] 
detect/tls: Improve tls.fingerprint rule handling

Issue: 4581

This commit improves the runtime performance of rules with
tls.fingerprint by using the inspection logic from tls.cert_fingerprint.

(cherry picked from commit 63745a78790936c80f7042b1dfcb3e869e0acaea)

2 years agodetect/uri: Remove unnecessary include
Jeff Lucovsky [Sun, 11 Sep 2022 13:50:20 +0000 (09:50 -0400)] 
detect/uri: Remove unnecessary include

This commit removes an unnecessary #include for detect-uricontent.h

(cherry picked from commit 6bccd5aa30c03debc92c1e910d5f0dd1c6a9cc58)

2 years agodetect/pcre: don't use JIT if disabled 8296/head
Victor Julien [Fri, 16 Dec 2022 14:51:05 +0000 (15:51 +0100)] 
detect/pcre: don't use JIT if disabled

If we determined not to use JIT at start up, really don't use
JIT.

Bug: #5762.

2 years agoebpf: update deprecated API calls 8289/head
Sascha Steinbiss [Thu, 15 Sep 2022 13:57:13 +0000 (13:57 +0000)] 
ebpf: update deprecated API calls

This fixes build errors when libbpf 1.0 is used. It removes previously
deprecated API functions that were still in use in Suricata's eBPF
code.

2 years agonfs4: fix write record handling
Philippe Antoine [Fri, 17 Jun 2022 09:32:17 +0000 (11:32 +0200)] 
nfs4: fix write record handling

Ticket: #5280
(cherry picked from commit 95f042442304ba8498c6409968f24b7b3c53ffc2)

2 years agoradix: fix ipv6 address parsing warning 8268/head
Victor Julien [Thu, 8 Dec 2022 19:14:43 +0000 (20:14 +0100)] 
radix: fix ipv6 address parsing warning

The check meant to see if the ip address part of the ip/cidr combo
was more specific than needed wasn't fully implemented, leading to
warnings being issued on completely valid and correct input.

This patch implements the same logic as in IPv4. If the ip address
as specified is different from the ip after the mask has been applied,
a warning is displayed.

Bug: #5747.
(cherry picked from commit 991f9fde3292d45eefcfe9e01ef8480e5864977b)

2 years agomime: do not skip empty lines for quoted-printable 8238/head
Philippe Antoine [Fri, 2 Dec 2022 13:43:10 +0000 (14:43 +0100)] 
mime: do not skip empty lines for quoted-printable

As these lines are in the file...

Ticket: #5725
(cherry picked from commit 0e054af1acda120a011d5d8136bc9a15cdac2f51)

2 years agomime/base64: unify space handling
Victor Julien [Sat, 3 Dec 2022 06:37:43 +0000 (07:37 +0100)] 
mime/base64: unify space handling

(cherry picked from commit 7bfb63210e3a128c999343a4805b1d972ae64b73)

2 years agoeve: add common options to loggers missing it
Philippe Antoine [Fri, 4 Nov 2022 08:52:07 +0000 (09:52 +0100)] 
eve: add common options to loggers missing it

So that we get community id for RFB for instance

Ticket: #5723

2 years agosmb: fix file reopening issue
Victor Julien [Wed, 30 Nov 2022 05:44:40 +0000 (06:44 +0100)] 
smb: fix file reopening issue

Fuzzing highlighted an issue where a command sequence on the same file
id triggered a logging issue:

file data for id N
close id N
file data for id N

If this happened in a single blob of data passed to the parser, the
existing file tx would be reused, the file "reopened", confusing the
file logging logic. This would trigger a debug assert.

This patch makes sure a new file tx is created for the file data
coming in after the first file tx is closed.

Bug: #5567.
(cherry picked from commit 45eb038e63604766de2828f6f25d145fea040424)

2 years agochangelog: minor formatting fixup
Victor Julien [Tue, 29 Nov 2022 09:22:36 +0000 (10:22 +0100)] 
changelog: minor formatting fixup

2 years agoversion: require libhtp 0.5.42
Victor Julien [Tue, 29 Nov 2022 09:22:02 +0000 (10:22 +0100)] 
version: require libhtp 0.5.42

2 years agoversion: start development towards 6.0.10
Victor Julien [Tue, 29 Nov 2022 09:21:24 +0000 (10:21 +0100)] 
version: start development towards 6.0.10

2 years agorelease: 6.0.9; update changelog suricata-6.0.9
Victor Julien [Mon, 28 Nov 2022 06:17:53 +0000 (07:17 +0100)] 
release: 6.0.9; update changelog

2 years agoflow: cleanup and clarify ancient debug messages
Victor Julien [Thu, 20 Oct 2022 13:24:52 +0000 (15:24 +0200)] 
flow: cleanup and clarify ancient debug messages