Bug #9067
closedlua/smtp: get_tx() ignores the current tx id and returns state->curr_tx
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():
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.
VJ Updated by Victor Julien about 2 months ago
- Status changed from New to In Progress
- Assignee changed from OISF Dev to Victor Julien
JI Updated by Jason Ish about 1 month ago
- Status changed from In Progress to In Review
MR1382