Commit Graph

16308 Commits (d43154adbe0e3b2cd66b9334d6cbe58523b23f26)
 

Author SHA1 Message Date
Giuseppe Longo d43154adbe sip: add sip.content_length sticky buffer
This adds a sticky (multi) buffer to match the "Content-Length" header field in
both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo 6f727ab970 sip: add sip.content_type sticky buffer
This adds a sticky (multi) buffer to match the "Content-Type" header field in
both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo 5e8e61bb3b sip: add sip.user_agent sticky buffer
This adds a sticky (multi) buffer to match the "User-Agent" header field in
both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo 6ddc7d6223 sip: add sip.via sticky buffer
This adds a sticky (multi) buffer to match the "Via" header field in
both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo c205e87911 sip: add sip.to sticky buffer
This adds a sticky (multi) buffer to match the 'To' header field in
both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo e3fefcf55c sip: add sip.from sticky buffer
This adds a sticky (multi) buffer to match the "From" header field
in both requests and responses.

Ticket #6374
5 months ago
Giuseppe Longo fbc3cd1b3f rust/sip: store response headers
To match on response SIP headers, those headers must be stored.

Ticket #6374
5 months ago
Giuseppe Longo cfb793ce28 rust/sip: store multiple header values
According to RFC 3261, a single header can be repeated one or more times,
and its name can also be specified using the 'compact form.'

This patch updates the hashmap used for storing headers to accommodate multiple
values instead of just one.

Additionally, if a header name is defined in the compact form, it is expanded
into its long form (i.e., the standard name).

This conversion simplifies the logic for matching a given header
and ensures 1:1 parity with keywords.

Ticket #6374
5 months ago
Giuseppe Longo 969f4d131f sip: rustify sticky buffers
Ticket #7204
5 months ago
Jeff Lucovsky 8f107c8252 detect: Clear errno before strtoul
Per the notes for strtoul, since 0 or ULONG_MAX is a legitimate return
value, errno must be cleared before the call so an error can be checked
after the call by testing errno.

Issue: 7126
5 months ago
Jeff Lucovsky a115acf208 smtp: Prevent error messages on packet path
Issue: 7126

This commit abandons the use of StringParseUint32 which generates an
error message of there are non-numeric characters.

The SMTP parser had used this function on the packet path; this commit
uses strtoul instead.

An example of the content causing the error message to be emitted:

    3460 LAST
5 months ago
Juliana Fajardini 2b1ad81cf5 pgsql: trigger raw stream reassembly at tx completion
Once we are tracking tx progress per-direction for PGSQL, we can trigger
the raw stream reassembly, for detection purposes, as soon as the
transactions are completed in the given direction.

Task #7000
5 months ago
Juliana Fajardini dcccbb1196 pgsql: track transaction progress per direction
PGSQL's current implementation tracks the transaction progress without
taking into consideration flow direction, and also has indirections
that make it harder to understand how the progress is tracked, as well
as when a request or response is actually complete.

This patch introduces tracking such progress per direction and adds
completion status per direction, too. This will help when triggering
raw stream reassembly or for unidirectional transactions, and may be
useful when we implement sub-protocols that can have multiple requests
per transaction, as well.

CancelRequests and TerminationRequests are examples of unidirectional
transactions. There won't be any responses to those requests, so we can
also mark the response side as done, and set their transactions as
completed.

Bug #7113
5 months ago
Juliana Fajardini 2c7824a41f pgsql: use new API style for extern C functions 5 months ago
Juliana Fajardini 3ba179422d pgsql: order StateProgress enum per direction
Related to
Bug #7113
5 months ago
Juliana Fajardini 7aeb718dd7 pgsql: apply rust fmt changes 5 months ago
Juliana Fajardini ef63aa50e2 doc/configuration: improve emergency-recovery docs
When removing mentions to `prune-flows` a few inconsistencies for how
we write and refer to `emergency-recovery` were left behind, still.
5 months ago
Victor Julien 51392a6af1 eve/flow: turn error into debug assertion
In case this hits logging an error is harmful, better to silently
continue.

Remove use of `default` to help the compiler flag new enum additions.
5 months ago
Victor Julien b3ed752cf1 eve/flow: log flow state directly
No need to first turn it into a flags field.
5 months ago
Philippe Antoine de9413c654 detect: safety for app-layer logging of stream-only rules
If a stream-only rule matches, and we find a tx where we
want to log the app-layer data, store into the tx data that
we already logged, so that we do not log again the app-layer metadata

Ticket: 7085
5 months ago
jason taylor f46a8776ec doc: add note about big endian for icmp_seq match 5 months ago
Juliana Fajardini 1420c83a87 doc/configuration: remove mention to prune-flows
Although the `prune-flows` option was removed with a5587fec2e,
when documentation for the suricata.yaml config file was added with
b252b0d, this option was also included - as has remained until now.
5 months ago
Philippe Antoine b3bd57246f ci: mov from cifuzz to clusterfuzzlite
To better support main7 CI fuzzing

Ticket: 7253
5 months ago
Jeff Lucovsky 51b742738c output/json: Remove unneeded parameters
Issue: 4974

Remove unused parameters in output path for
- AlertJsonMetadata
- AlertJsonHeader
5 months ago
Jeff Lucovsky a7b70ce5ce config: Update reference keys
Issue: 4974

1. Use https instead of http everywhere
2. Organize and annotate references by
    - Referenced by ET/Open and ET/Pro
        - URL resolves and works as intended (to provide supplemental
          information regarding a reference value, e.g., bug id, cve
          value)
        - URL no longer resolves
        - URL resolves but doesn't work as intended (to provide
          supplemental information)
    - Not referenced by ET/Open nor ET/Pro
        - URL resolves and works as intended (to provide supplemental
          information regarding a reference value, e.g., bug id, cve
          value)
        - URL no longer resolves
        - URL resolves but doesn't work as intended (to provide
          supplemental information)
5 months ago
Jeff Lucovsky 8064847fc6 doc: Document reference config setting
Issue: 4974
5 months ago
Jeff Lucovsky 9bc468e63a alert/reference: Optionally add reference(s)
Issue: 4974

Optionally include rule references with the alert. Since there can be
multiple reference keywords, they are collected into an array.
5 months ago
Philippe Antoine d3eb6569d2 rust: pin serde version
because oss-fuzz does not support newer rust nightly
and newer serde does not support oss-fuzz old nightly
6 months ago
Jason Ish 85ee2f882f lua: use lua from crates.io rather than github
This allows the source override in .cargo/config.toml to apply to the
suricata-lua-sys crate as well fixing offline builds.

Ticket: #7226
6 months ago
Shivani Bhardwaj fbb97c51e4 dcerpc: return error on invalid header
DCERPC/TCP tends to return the same values for invalid and incomplete
headers. As a result of this, invalid headers and any traffic following
it is buffered and processed later on assumed to be valid DCERPC traffic.
Fix this by clearly defining error and incomplete data and taking
appropriate actions.

Bug 7230
6 months ago
Philippe Antoine 31bed10ff6 runmode: fix coverity warning
CID 1619284:  Memory - illegal accesses  (OVERRUN)

In ParseAFXDPConfig, a pointer to bool is cast into a pointer
to int.

Also removing the cast pattern when useless
6 months ago
Philippe Antoine dc3c048b49 rust/detect: fix too_long_first_doc_paragraph clippy warning
warning: first doc comment paragraph is too long
  --> src/detect/iprep.rs:57:1
   |
57 | / /// value matching is done use `DetectUintData` logic.
58 | | /// isset matching is done using special `DetectUintData` value ">= 0"
59 | | /// isnotset matching bypasses `DetectUintData` and is handled directly
60 | | /// in the match function (in C).
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
   = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line
6 months ago
Philippe Antoine 2a984e3b13 rust/dcerpc: fix single_match clippy warning
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/dcerpc/log.rs:36:33
   |
36 |               DCERPC_TYPE_BIND => match &state.bind {
   |  _________________________________^
37 | |                 Some(bind) => {
38 | |                     jsb.open_array("interfaces")?;
39 | |                     for uuid in &bind.uuid_list {
...  |
51 | |                 None => {}
52 | |             },
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default
6 months ago
Philippe Antoine 89d229c76f frames: do not rely on FRAME_STREAM_ID
As it is not always the first frame to be created :
if it is not enabled, it does not get created, and other enabled
frames may be created first. see use of FrameConfigTypeIsEnabled

This resulted that this other frame got its length updated
on stream end, which led to false positives.

Resorting on FRAME_STREAM_TYPE is more consistent.

Ticket: 7213
6 months ago
Philippe Antoine 0ebb84538e http2: add frames support
Ticket: 5743

Why ? To add detection capabilities
6 months ago
Victor Julien 65392c02f5 dcerpc: don't reuse completed tx
In the DCERPC over TCP pcap, logging and rule matching is disrupted by adding a simple rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )

Works: alert + 3 dcerpc records.

But when adding a trivial rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )
        alert tcp any any -> any any (dsize:3; sid:2; rev:1; )

The alert for sid:1 disappears and also there is one dcerpc event less.

In the single rule case we can aggressively free the transactions, as there
is only an sgh in the toserver direction.

This means that when we encounter the 2nd REQUEST, the first 2 transactions
have already been processed and freed. So for the 2nd REQUEST we open a new
TX and run inspection and logging on it.

When the 2nd rule is added, it adds toclient sgh as well. This means that we
will now slightly delay the freeing of the transactions.

As a consequence we still have the TX for the first REQUEST when the 2nd REQUEST
is parsed. This leads to the 2nd REQUEST re-using the TX. Since the TX is
already marked as inspected, it means the toserver rule now no longer matches.
Also we're not logging this TX correctly now.

This commit fixes the issue by not "finding" a TX that as already been
marked complete in the search direction.

Bug #7187.
6 months ago
Victor Julien 79aa4861e0 detect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN
The `app-layer-protocol` keyword inconsistently checks whether the
alproto is ALPROTO_UNKNOWN. In the regular match function it isn't
checked, in the prefilter function its checked for all but the "either"
mode.

This leads to false positives for negated matching, as an expression
like "!tls" will match if checked against ALPROTO_UNKNOWN.

This patch adds the checking everywhere. The keyword returns no match as
long as the alproto is ALPROTO_UNKNOWN.

Bug: #7241.
6 months ago
Philippe Antoine 84735251b5 tls/ja3: do not append to ja3 str once ja3 hash is computed
Ticket: 6634

That means take only the first client hello into account.
This way, we do not end with ja3 string with 9 commas...
6 months ago
Shivani Bhardwaj e93743a094 rust/base64: upgrade crate to latest
base64 crate is updated to the latest version 0.22.1. This came with
several API changes which are applied to the code. The old calls have
been replaced with the newer calls.

This was done following the availability of better fns to directly
decode into slices/vectors as needed and also that previous version was
too old.
Along with this change, update the Cargo.lock.in to reflect all changes
in the package versions.

Task 7219
6 months ago
Shivani Bhardwaj 599a451e44 rust: update Cargo.lock.in
to include the latest packages available.
6 months ago
dependabot[bot] 0037f1e0f4 github-actions: bump github/codeql-action from 3.25.15 to 3.26.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.15 to 3.26.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.25.15...v3.26.6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
6 months ago
dependabot[bot] aef10c735c github-actions: bump actions/upload-artifact from 4.3.4 to 4.4.0
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.4.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](0b2256b8c0...50769540e7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
6 months ago
Jason Ish 685baa9680 output-filedata: rename and document registration function
Prefix registration function and pointer function type with SC, as
well as document.

Ticket: #7227
6 months ago
Jason Ish b51eeb3ab5 output-file: rename and document registration function
Rename OutputRegisterFileLogger to SCOutputRegisterFileLogger, add
function documentation and include in userguide.

Ticket: #7227
6 months ago
Jason Ish 14b648f286 output-streaming: rename and document registration
Prefix the registration function and types with "SC", and add function
documentation.

Ticket: #7227
6 months ago
Jason Ish cba8527f75 output-file: use void *initdata instead of OutputCtx
Avoids leaking a higher level abstraction into a low level logger.

Ticket: #7227
6 months ago
Jason Ish 80d395efbb output-filedata: use void *initdata instead of OutputCtx
Avoids leaking a higher level abstraction into a low level logger.

Ticket: #7227
6 months ago
Jason Ish c02e7099b7 output-streaming: use void *initdata instead of OutputCtx
Using OutputCtx leaks a higher level abstraction into the low level
logger.

Ticket: #7227
6 months ago
Jason Ish fe69dd972a output: remove remaining ThreadExitPrintStats callbacks
Not used in output modules.

Ticket: #7227
6 months ago
Jason Ish d88d8fc4f0 output-stats: remove ThreadExitPrintStats callback
Not used.

Ticket: #7227
6 months ago