Skip to content

Fw backports/v7.2f - #15854

Draft
victorjulien wants to merge 64 commits into
OISF:main-8.0.xfrom
victorjulien:fw-backports/v7.2f
Draft

Fw backports/v7.2f#15854
victorjulien wants to merge 64 commits into
OISF:main-8.0.xfrom
victorjulien:fw-backports/v7.2f

Conversation

@victorjulien

@victorjulien victorjulien commented Jul 10, 2026

Copy link
Copy Markdown
Member

jasonish and others added 30 commits July 10, 2026 15:02
Add minimal SMTP progress states to support envelope validation before
moving to data.

Update SMTP, file and email keywords to hook into the appropriate
states.

Purposefully kept minimal for now as to not break the current idea of an
SMTP transaction, which is probably not ideal for firewall mode.

Ticket: OISF#8393
(cherry picked from commit c2728ee)
Add directionality to completion states, and replace tx->done by checking for
both directions being complete.

This means that the transaction is now not complete until the server responds
to the clients of data marker, previously the tx was completed when the client
send end of data without waiting for the server response.

This keeps smtp:response_complete from being exposed before the server response
is parsed.

Ticket: OISF#8393
(cherry picked from commit 7b31f41)
Track the transaction id for each queued SMTP command so replies can update the
transaction that created the command instead of always using the current
transaction.

Ticket: OISF#8393
(cherry picked from commit e2a62dd)
Also ensures that a quit or rset without a helo still creates a tx.

Ticket: OISF#8728
(cherry picked from commit 842b14e)
Don't allow trailing :

(cherry picked from commit 7fe8f63)
It used the alstate name where it meant tx.

(cherry picked from commit 280a1e5)
Fixes: 833a738 ("http: fail tx creation if we cannot allocate user data")
(cherry picked from commit 5a770ad)
Since pstate can't be NULL, remove the conditional logic.

(cherry picked from commit f4f5212)
Extend the app-layer-protocol keyword to accept a pipe-separated list of
protocol values, so a single rule can match any of several protocols:

    app-layer-protocol:[!]<proto1>|<proto2>[|...][,<qualifier>]...;

A non-negated list matches when the flow's protocol equals any listed value
(OR); a negated list matches when it equals none of them (NOR). The
single-value form and the trailing mode qualifier are unchanged.

Matching keeps the historical AppProtoEquals() equivalences by default
(dns/doh2, http/http1/http2, dcerpc/smb, ...). An `exact` qualifier selects
strict identity matching with no equivalences and no http umbrella; it
combines with a direction mode in any order. Because a flow is never the
generic ALPROTO_HTTP, `http,exact` is rejected at load.

Values are expanded once at rule load into an effective match-set bitmask, so
the per-packet match is a single bitmask test. Single-value rules remain
prefilterable; multi-value rules are excluded from prefiltering and an
explicit prefilter on them is rejected. Conflicting keyword combinations
(duplicate or overlapping negations, mixed positive/negated) are rejected at
load. Engine-analysis reports the effective match set.

Ticket: 7705
(cherry picked from commit 43bc2db)
Ticket: 8518

Keywords that work for HTTP2 headers match now as soon as possible

A push promise is now considered like a headers frame with regards
to the progress (no dedicated "reserved" progress/state)

http.protocol and http.stat_msg keywords are now registered at
earliest progress, since these are synthetic like "HTTP/2" and
not really seen on the wire.

http.request_line and http.response_line match only on data,
and not on headers, since we must wait the end of headers
to be sure to have the full line

http2.size_update now matches at headers progress as it should

http2.frametype, http2.errorcode, http2.priority now match like
http2.window, when the tx is complete from both sides, as a
half-closed client may still send priority, rst_stream
or window_update frames

(cherry picked from commit daf68dc)
Ticket: 8518

Meaning they will now match only once per tx instead of twice:
once for each direction

(cherry picked from commit 8eed90c)
Ticket: 8518
(cherry picked from commit 26bb18c)
Allow registration of per substate progress name mappings.

Implement logic for getting sub-state names, id's.

Add transaction type and end of progress values to AppLayerTxData.

Introduce helpers to keep logic clean.

(cherry picked from commit b6bc025)
Support for per transaction sub states: different state machines per
transaction type.

Skip engines not belonging to our substate.

Store tx_type in DetectTransaction.

Each protocol supporting sub states will register states from 1 and up.

To support:

Ticket: OISF#8386.
(cherry picked from commit 95365ce)
Split into 2 sub-states:
- stream, which has the "HTTP" requests and responses, including DOH2
- global, which has the settings and other global or control handling

Introduce a simpler progress tracking for the global sub state:
- HTTP2ProgGlobalStart and HTTP2ProgGlobalComplete.

The stream sub state uses the same state machine as before.

Ticket: OISF#8386.
(cherry picked from commit 7ebc699)
Hard coded for now.

(cherry picked from commit c943de4)
Each keyword supporting DOH2 must register explicitly

(cherry picked from commit 1bb843d)
Now that DNS keywords are no longer registered for DOH2, the keywords
need to manually registered for DOH2.

(cherry picked from commit b36ec14)
Now that HTTP keywords are no longer automatically registered for
HTTP/2, register them manually.

(cherry picked from commit 17953d2)
Now that there is a policy hash, make the alert signature object a
member of that to avoid another hash table lookup.

(cherry picked from commit 3b6b381)
Check that sub state handling is correct.

(cherry picked from commit 2e1003a)
In preparation of being able to log it.

(cherry picked from commit 7e60c32)
(cherry picked from commit e1e24d6)
http2 states were not yet supported even if the built-in states could
already work. Clearly error out on a hook w/o substate.

(cherry picked from commit 7517ba9)
(cherry picked from commit f02a427)
In firewall mode the alproto logic when building prefilter and rule
engines is strict, but was out of sync between prefilter and rule app
inspect engines.

For SIGNATURE_HOOK_TYPE_APP rules the logic is strict, with an exception
for HTTP/2 and DOH2. DOH2 is not a full protocol implementation, but
rather HTTP/2 with a different alproto.

Fixes: d64954a ("detect: don't register unrelated inspect engines")
(cherry picked from commit f8f28c6)
This is to make the hook use names consistent with the default
hooks and other protocols.

(cherry picked from commit cf216b6)
DOH2 depends on HTTP/2, so it makes no sense to enable it separately.

It would also put the sub state handling in a weird state, as the DOH2
side reuses the registered HTTP/2 callbacks.

(cherry picked from commit f545f06)
When building the per signature app_inspect list, only add engines
that match the sub state specified in the hook.

(cherry picked from commit a824d97)
Register HTTP/2 and DOH2 this way.

(cherry picked from commit 89baff0)
Make sure that every buffer in a signature is actually used in the
setup of the engines. Reject sigs that are locked to a certain substate
and use buffers that require another.

(cherry picked from commit 8a5e8c6)
Add substates to the --list-app-layer-hooks option.

(cherry picked from commit 8455efd)
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.69897% with 219 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.64%. Comparing base (37622a5) to head (94296e8).

❗ There is a different number of reports uploaded between BASE (37622a5) and HEAD (94296e8). Click for more details.

HEAD has 13 uploads less than BASE
Flag BASE (37622a5) HEAD (94296e8)
suricata-verify 3 1
unittests 3 1
netns 3 1
pcap 3 1
livemode 3 1
fuzzcorpus 3 0
Additional details and impacted files
@@              Coverage Diff               @@
##           main-8.0.x   #15854      +/-   ##
==============================================
- Coverage       81.67%   76.64%   -5.03%     
==============================================
  Files            1016     1016              
  Lines          276979   278189    +1210     
==============================================
- Hits           226213   213231   -12982     
- Misses          50766    64958   +14192     
Flag Coverage Δ
fuzzcorpus ?
livemode 18.74% <29.22%> (+0.10%) ⬆️
netns 20.34% <50.10%> (+0.18%) ⬆️
pcap 44.41% <52.27%> (-0.03%) ⬇️
suricata-verify 65.25% <83.95%> (+0.09%) ⬆️
unittests 58.62% <59.31%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suricata-qa

Copy link
Copy Markdown

WARNING:

field baseline test %
SURI_TLPW2_single_stats_chk
.uptime 1393 1348 96.77%
SURI_TLPW2_autofp_stats_chk
.uptime 184 176 95.65%
SURI_TLPW1_stats_chk
.uptime 215 208 96.74%
SURI_TLPR1_stats_chk
.app_layer.tx.smtp 613619 386549 62.99%
IPS_AFP_stats_chk
.app_layer.tx.smtp 74520 37800 50.72%
TREX_GENERIC_stats_chk
.app_layer.tx.smtp 29542 14771 50.0%

Pipeline = 32560

@lukashino

Copy link
Copy Markdown
Contributor

@yashda , just FYI, the update with the default firewall policy is in #15951

@yashda

yashda commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@lukashino, can we also merge tcp.session (#15940) PR in #15951?

@yashda

yashda commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

We also found a backward-compatibility regression with muti-value support in app-layer-proto keyword (#15819). Rules with multiple negated values(e.g. app-layer-protocol:!http1; app-layer-protocol:!http2) are not supported anymore and will cause rule load failure. I am working on it.

@lukashino

Copy link
Copy Markdown
Contributor

Hi, yes, let me look at that tomorrow. I'll rebase your work on top of #15951

I am working on it.

Thank you. Let us know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants