Skip to content

Commit

Permalink
doc: Initial doc for lua sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
J0eJ0h committed Feb 5, 2024
1 parent 19a55dc commit 678c84f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
14 changes: 12 additions & 2 deletions doc/userguide/configuration/suricata-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2752,8 +2752,9 @@ Beyond suricata.yaml, other ways to harden Suricata are
Lua
~~~

Suricata 7.0 disables Lua rules by default. Lua rules can be enabled
in the ``security.lua`` section of the configuration file:
Suricata 8.0 sandboxes Lua rules by default. The restrictions on the sandbox for Lua rules can be
modified in the ``security.lua`` section of the configuration file. Additionally, Lua rules
can be completely disabled the same as the Suricata 7.0 default:

::

Expand All @@ -2762,3 +2763,12 @@ in the ``security.lua`` section of the configuration file:
# Allow Lua rules. Disabled by default.
#allow-rules: false

# Upper bound of allocations by a Lua rule before it will fail
#max-bytes: 500000

# Upper bound of lua instructions by a Lua rule before it will fail
#max-instructions: 500000

# Allow dangerous lua operations like external packages and file io
#allow-restricted-functions: false

26 changes: 25 additions & 1 deletion doc/userguide/rules/lua-detection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Syntax:

The script filename will be appended to your default rules location.

The script has 2 parts, an init function and a match function. First, the init.
The script has 2 parts, an init function and a match function. First, the init.
Additionally, the script will run in a limited sandbox by default.

Init function
-------------
Expand Down Expand Up @@ -100,5 +101,28 @@ Entire script:
return 0
Sandbox and Available functions
-------------------------------

By default, the maximum memory and lua instruction count per execution of a detection rule will be limited. Additionally,
The following libraries and functions are blocked:
* package
* coroutine
* io
* os
* collectgarbage
* dofile
* getmetatable
* loadfile
* load
* pcall
* setmetatable
* xpcall
* string.rep

This behavior can be modified via the ``security.lua`` section of :ref:`suricata-yaml`

.. note:: Suricata 8.0 has moved to Lua 5.4 and has builtin support for bitwise and utf8 operations now.

A comprehensive list of existing lua functions - with examples - can be found at :ref:`lua-functions` (some of them, however,
work only for the lua-output functionality).

0 comments on commit 678c84f

Please sign in to comment.