Project

General

Profile

Actions

Bug #9067

closed
VJ VJ

lua/smtp: get_tx() ignores the current tx id and returns state->curr_tx

Bug #9067: lua/smtp: get_tx() ignores the current tx id and returns state->curr_tx

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: wrong-transaction data (detection evasion / log corruption)
  • Component: src/util-lua-smtp.c:44-75 (LuaSmtpGetTx)

Description

smtp.get_tx() ignores the current transaction id and returns state->curr_tx directly (:60) instead of LuaStateGetTX():

SMTPTransaction *tx = state->curr_tx;

The registry tx (set per rule call and per output callback, detect-lua-extensions.c:57-63, output-lua.c:90-91/304) is the transaction being inspected/logged. curr_tx advances as soon as the next request is parsed (app-layer-smtp.c:1335-1342) and is NULLed when the parser frees the transaction (:2015-2016), even though the requested tx is still in the list (SMTPStateGetTx, :2040-2056).

Trigger: multi-tx/pipelined SMTP flows (e.g. the smtp-bdat-pipelined-next-mail pcaps). A Lua rule on tx#N or the SMTP output logger for tx#N receives tx#N+1's mail_from/rcpt_to/MIME fields while args["tx_id"] names tx#N; when curr_tx is NULL the call errors although the requested tx still exists.

Fix direction

Use LuaStateGetTX() with a NULL check, like dns/ssh/ntp do.

Test

lua-smtp-gettx-multitx: pipelined two-mail pcap; assert get_tx():get_mail_from() belongs to args.tx_id in both rule and output contexts.


Subtasks 1 (0 open — 1 closed)

Bug #9317: lua/smtp: get_tx() ignores the current tx id and returns state->curr_tx (8.0.x backport)ClosedVictor JulienActions
Actions

Also available in: PDF Atom