IMAP protocol parser, logger and sticky buffers v7#15617
Closed
glongo wants to merge 4 commits into
Closed
Conversation
This introduces a parser for IMAP protocol.
An IMAP transaction has two states driven by the 'complete' field:
- Open (complete = false): waiting for a matching tagged response.
- Complete (complete = true): tagged response received, or special
conditions met (BYE, server greeting).
Completion logic (is_complete):
- If a tagged request exists: requires a matching tagged response.
- No tagged request + BYE: complete (server closing).
- No tagged request + any response: complete (server greeting).
Transactions are created in three places:
1. Request parser: every parsed command creates a new tx.
2. Response parser (tagged, no matching request): midstream/async;
orphan tagged response gets its own tx.
3. Response parser (untagged, no incomplete tx): server greeting or
unsolicited response.
Once open, messages accumulate:
- Request side: continuation and literal data attach to the most
recent incomplete tx.
- Response side: untagged responses attach to the most recent
incomplete tx; tagged responses attach via find_request(tag).
Email extraction happens at most once per tx:
- From literal data in APPEND commands (request side).
- From FETCH response data (response side).
Six hard limits prevent unbounded growth:
- IMAP_MAX_TX (256, configurable): total transactions. Exceeded:
all incomplete txs force-completed with TooManyTransactions event.
- IMAP_MAX_MSGS_PER_TX (512): requests/responses per tx. Exceeded:
message silently dropped.
- IMAP_MAX_LINES (512): request/response lines per tx. Exceeded:
line silently dropped.
- IMAP_MAX_HEADERS (512): headers in ImapParsedEmail. Exceeded:
TooManyHeaders event.
- IMAP_MAX_BODY_SIZE (10 MB): email body in ImapParsedEmail.
Exceeded: body truncated, BodyTooLarge event.
- Literal size (u32): bounded by declared size in {N} specifier.
IMAP_MAX_TX is the only configurable limit, via
app-layer.protocols.imap.max-tx.
Ticket OISF#8276
This introduces a logger for IMAP protocol. Ticket OISF#8276
This implements the following sticky buffers for IMAP protocol: - imap.request - imap.response The following frames have been added: - imap.body - imap.headers - imap.pdu The following email sticky buffers have been updated to work with IMAP: - email.from - email.subject - email.to - email.cc - email.date - email.message_id - email.x_mailer The following email sticky buffers have been added and are supported only for IMAP: - email.command - email.body - email.header - email.header.name - email.header.value Ticket OISF#8276
|
Information: QA ran without warnings. Pipeline = 31997 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #15617 +/- ##
==========================================
- Coverage 82.89% 82.83% -0.07%
==========================================
Files 1006 1009 +3
Lines 273487 276035 +2548
==========================================
+ Hits 226710 228654 +1944
- Misses 46777 47381 +604
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Replaced with #15648 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
email.body_md5compatible with IMAPLink to ticket: https://redmine.openinfosecfoundation.org/issues/8276
Previous PR: #15400
SV_BRANCH=OISF/suricata-verify#2908