8000 Smtp inspection fix/v3 by inashivb · Pull Request #13550 · OISF/suricata · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Smtp inspection fix/v3 #13550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Conversation

inashivb
Copy link
Member

Link to ticket: https://redmine.openinfosecfoundation.org/issues/7783

Restores behavior from the past rejected PR b4c51d3 as that was correct.

Previous PR: #13507

Changes since v2:

  • broke the commits; made message clearer
  • also covered the anomaly case (trigger inspection even in case of anomaly)
  • rebased on top of latest master

NOTE: Requires upgrading of at least one internal test.

inashivb added 3 commits June 30, 2025 15:57
to build the correct behavior. As a part of ab01a1b, in order to match
the behavior in master, the calls for triggering raw stream inspection
were made when communication in one direction for a transaction was
completed. However, it was incorrect to do so. Reliable inspection
requires any request line/response line to be completed.

Bug 7783
Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

SMTP parser can handle multiple command lines per direction. Appropriate calls
to trigger raw stream inspection have been added on succesful parsing of each
request line and response line.

For the requests, the call to trigger inspection has been added in the
beginning rather than the completion of transactions. This does not
affect the inspection as it is actually triggered in the following call.
This covers the case for anomaly as well. There are two benefits for
this:
- immediate inspection for anomalous data
- flushing of the anomalous data making next data's inspection cleaner

Bug 7783
Copy link
codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.51%. Comparing base (055d270) to head (4171a74).
Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13550   +/-   ##
=======================================
  Coverage   83.51%   83.51%           
=======================================
  Files        1011     1011           
  Lines      275053   275052    -1     
=======================================
+ Hits       229707   229715    +8     
+ Misses      45346    45337    -9     
Flag Coverage Δ
fuzzcorpus 61.82% <100.00%> (+0.05%) ⬆️
livemode 19.09% <0.00%> (+0.13%) ⬆️
pcap 44.68% <100.00%> (-0.02%) ⬇️
suricata-verify 65.05% <100.00%> (-0.02%) ⬇️
unittests 59.17% <85.71%> (-0.01%) ⬇️

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

Information: QA ran without warnings.

Pipeline = 26665

@victorjulien victorjulien added this to the 8.0 milestone Jun 30, 2025
Copy link
Contributor
@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work,

CI : ✅ (not sure about the internal test you are mentioning)
Code : good
Commits segmentation : ok
Commit messages : good (I do not know if we are doing reverts)
Git ID set : looks fine for me
CLA : you already contributed
Doc update : nice
Redmine ticket : ok
Rustfmt : no rust
Tests : Should we have a SV test ?
Dependencies added: none

@victorjulien
Copy link
Member

Merged in #13557, thanks!

@inashivb inashivb deleted the smtp-inspection-fix/v3 branch July 1, 2025 07:00
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.

4 participants
0