]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lua: disable lua rules by default
authorJason Ish <jason.ish@oisf.net>
Wed, 7 Jun 2023 22:35:53 +0000 (16:35 -0600)
committerVictor Julien <vjulien@oisf.net>
Wed, 14 Jun 2023 05:10:57 +0000 (07:10 +0200)
To protect against possible supply chain attacks, disable Lua rules by
default. They can be enabled under the "security" section of
suricata.yaml.

Ticket: #6122

src/detect-lua.c
suricata.yaml.in

index 680aee34f3bb1227f0ddf71ae1ad2ef23612e49d..18302cf7bdadd116728e8fee92538ba7d2304208 100644 (file)
@@ -1015,6 +1015,15 @@ static int DetectLuaSetup (DetectEngineCtx *de_ctx, Signature *s, const char *st
     DetectLuaData *lua = NULL;
     SigMatch *sm = NULL;
 
+    /* First check if Lua rules are enabled, by default Lua in rules
+     * is disabled. */
+    int enabled = 0;
+    (void)ConfGetBool("security.lua.allow-rules", &enabled);
+    if (!enabled) {
+        SCLogError("Lua rules disabled by security configuration: security.lua.allow-rules");
+        goto error;
+    }
+
     lua = DetectLuaParse(de_ctx, str);
     if (lua == NULL)
         goto error;
@@ -1169,6 +1178,8 @@ static void DetectLuaFree(DetectEngineCtx *de_ctx, void *ptr)
 /** \test http buffer */
 static int LuaMatchTest01(void)
 {
+    ConfSetFinal("security.lua.allow-rules", "true");
+
     const char script[] =
         "function init (args)\n"
         "   local needs = {}\n"
index f9a575d726274aafe8d547615acfde28fa95f844..2b7fd3bef497ccf9ff52dad6f43fd68879ad6ef8 100644 (file)
@@ -1191,6 +1191,10 @@ security:
         - /etc/
         - @e_sysconfdir@
 
+  lua:
+    # Allow Lua rules. Disabled by default.
+    #allow-rules: false
+
 # Some logging modules will use that name in event as identifier. The default
 # value is the hostname
 #sensor-name: suricata