Bug #9068
closedlua/dnp3: get_tx() can exhaust the sandbox memory budget -> silent no-match (detection bypass)
Description
- Status: present in
main(9b7938aec); code-confirmed mechanism - Class: sandbox memory-budget exhaustion caused by attacker-sized data -> silent rule no-match (detection bypass)
- Component:
src/util-lua-dnp3.c:158-193(DNP3GetTx) +src/util-lua-sandbox.c:67-71,src/detect-lua.c:176-205
Description¶
dnp3.get_tx() materializes the whole transaction into Lua tables (one table per object and per point, util-lua-dnp3.c:48-95) with the size driven by the packet-controlled point count (max-points default 16384, app-layer-dnp3.c:95, :875-885). Each point costs roughly 120-500 bytes of Lua state, so about 4k single-bit points - expressible in a \~0.5 KB bit-packed G1V1 payload (one \~510-byte reassembled app message, a few link frames) - exceed the default security.lua.max-bytes of 500000 (util-lua-common.h:27). Up to \~2-8 MB at the cap.
When the allocator refuses (LuaAlloc, util-lua-sandbox.c:67-71), the call fails with LUA_ERRMEM; DetectLuaRunMatch classifies it as a memory-limit error and returns 0 (detect-lua.c:176-205), so the lua: keyword - and therefore the whole rule - never fires for that flow. The engine stays healthy (no crash), but a large DNP3 response can suppress a rule; realistic on large class-0 polls even without an attacker.
Rule/luaxform states only (output states are deliberately unlimited).
Fix direction¶
Options: cap the number of points materialized per call (config or constant) and/or avoid building per-point tables for large transactions (lazy accessors); treat an exhausted budget as an explicit script error/event so the operator sees it; document the interaction between max-points and security.lua.max-bytes.
Test¶
lua-dnp3-huge-points: DNP3 response with >4k points under the default max-bytes; assert the documented behavior (no silent no-match; bounded memory).
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