Project

General

Profile

Actions

Bug #9083

closed
VJ VJ

lua/smtp: get_mime_list() skips the first MIME header

Bug #9083: lua/smtp: get_mime_list() skips the first MIME header

Added by Victor Julien 2 months ago. Updated 8 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

  • Status: present in main (9b7938aec); code-confirmed
  • Class: off-by-one in a list API (first element silently omitted)
  • Component: src/util-lua-smtp.c:99-118 (LuaSmtpTxGetMimeList) + rust/src/mime/smtp.rs:737-748

Description

get_mime_list() starts its index at num = 1 and passes that directly to the FFI, which uses it 0-based over the current MIME part's headers (headers[main_headers_nb + num]). The first header of the part is never returned.

Evidence: the existing suricata-verify/tests/lua/lua-smtplib test asserts fields[1] "Content-Transfer-Encoding" and #fields 2 for a part whose headers are actually [Content-Type, Content-Transfer-Encoding, Content-Disposition] - the dropped Content-Type (which can carry name=) is not asserted.

Trigger: any SMTP tx with MIME headers.

Fix direction

Pass num - 1 (or start from 0) so the first header is included; update the existing test to assert fields[1] "Content-Type" and #fields 3.

Test

lua-smtp-mime-list-first (or extend lua-smtplib).


Subtasks 1 (0 open — 1 closed)

Bug #9333: lua/smtp: get_mime_list() skips the first MIME header (8.0.x backport)ClosedVictor JulienActions
Actions

Also available in: PDF Atom