An SQL injection issue affects rsyslog deployments using the optional
omclickhouse output module. The module is not loaded by default.

CVE: CVE-2026-93404
Advisory: 
https://github.com/rsyslog/rsyslog/security/advisories/GHSA-8rx7-ww92-p4vr

The built-in ClickHouse INSERT template used SQL escaping that did not
account for ClickHouse backslash escapes. A sender able to submit a log
message routed to an affected action could alter the SQL sent to ClickHouse,
potentially forging stored log records or evaluating expressions with the
configured ClickHouse account's privileges.

Affected deployments use the built-in template or a custom INSERT template
with option.stdsql="on". The issue was introduced in rsyslog 8.1901.0. In
8.1901.0 the built-in template lacked a required SQL mode, while custom
stdSQL templates were exposed. Later releases used the vulnerable built-in
stdSQL template.

The source fix is attached. It changes the built-in template to
backslash-aware SQL escaping and requires custom string/list templates to
use option.sql="on". Plugin and subtree templates are rejected because
their renderers bypass ordinary field escaping. Operators can disable the
affected action or use a reviewed custom string/list template with
option.sql="on" until they can deploy a fixed build.

The designated fixed-version label is 2026-11-11 daily stable. This label
does not establish that any particular binary package is available;
distributions should verify their own build and package status. The source
patch and advisory are available at disclosure independently of upstream
merge and binary publication.

Severity: High; no CVSS vector has been assigned.
Credit: Found by Anthropic using Claude and manually validated by
David Korczynski of Ada Logics.

Regards,
Rainer Gerhards
rsyslog project

Minimal source patch: see the attached .patch file (preserved without
line wrapping).
diff --git a/plugins/omclickhouse/omclickhouse.c 
b/plugins/omclickhouse/omclickhouse.c
index a46adfc58..f520e4865 100644
--- a/plugins/omclickhouse/omclickhouse.c
+++ b/plugins/omclickhouse/omclickhouse.c
@@ -859,7 +859,7 @@ BEGINnewActInst
     CODE_STD_STRING_REQUESTnewActInst(1);
     CHKiRet(OMSRsetEntry(*ppOMSR, 0,
                          (uchar *)strdup((pData->tplName == NULL) ? " 
StdClickHouseFmt" : (char *)pData->tplName),
-                         OMSR_RQD_TPL_OPT_SQL));
+                         OMSR_RQD_TPL_OPT_SQL_BACKSLASH));
 
     if (server != NULL) {
         CHKiRet(computeBaseUrl((const char *)server, pData->port, 
pData->useHttps, pData));
diff --git a/runtime/action.c b/runtime/action.c
index 83970c996..4cb3ac8d3 100644
--- a/runtime/action.c
+++ b/runtime/action.c
@@ -2712,6 +2712,20 @@ rsRetVal addAction(action_t **ppAction,
                          "the SQL or stdSQL option in your template!\n");
                 ABORT_FINALIZE(RS_RET_RQD_TPLOPT_MISSING);
             }
+            if ((iTplOpts & OMSR_RQD_TPL_OPT_SQL_BACKSLASH) && 
(pAction->ppTpl[i]->optFormatEscape != SQL_ESCAPE)) {
+                errno = 0;
+                LogError(0, RS_RET_RQD_TPLOPT_MISSING,
+                         "Action disabled. To use this action, you have to 
specify "
+                         "the SQL option (option.sql=\"on\") in your 
template!\n");
+                ABORT_FINALIZE(RS_RET_RQD_TPLOPT_MISSING);
+            }
+            if ((iTplOpts & OMSR_RQD_TPL_OPT_SQL_BACKSLASH) &&
+                (pAction->ppTpl[i]->pStrgen != NULL || 
pAction->ppTpl[i]->bHaveSubtree)) {
+                errno = 0;
+                LogError(0, RS_RET_RQD_TPLOPT_MISSING,
+                         "Action disabled. Backslash-aware SQL escaping 
requires a string or list template!\n");
+                ABORT_FINALIZE(RS_RET_RQD_TPLOPT_MISSING);
+            }
             tplNoteUse(pAction->ppTpl[i], iTplOpts & OMSR_TPL_AS_DYNAFILE);
         }
 
diff --git a/runtime/objomsr.c b/runtime/objomsr.c
index 4e8ba0207..5df798806 100644
--- a/runtime/objomsr.c
+++ b/runtime/objomsr.c
@@ -142,7 +142,8 @@ int OMSRgetEntry(omodStringRequest_t *pThis, int iEntry, 
uchar **ppTplName, int
 rsRetVal OMSRgetSupportedTplOpts(unsigned long *pOpts) {
     DEFiRet;
     assert(pOpts != NULL);
-    *pOpts = OMSR_RQD_TPL_OPT_SQL | OMSR_TPL_AS_ARRAY | OMSR_TPL_AS_MSG | 
OMSR_TPL_AS_JSON | OMSR_TPL_AS_DYNAFILE;
+    *pOpts = OMSR_RQD_TPL_OPT_SQL | OMSR_TPL_AS_ARRAY | OMSR_TPL_AS_MSG | 
OMSR_TPL_AS_JSON | OMSR_TPL_AS_DYNAFILE |
+             OMSR_RQD_TPL_OPT_SQL_BACKSLASH;
     RETiRet;
 }
 
diff --git a/runtime/objomsr.h b/runtime/objomsr.h
index bc4f565c3..0047bd335 100644
--- a/runtime/objomsr.h
+++ b/runtime/objomsr.h
@@ -35,7 +35,9 @@
 #define OMSR_TPL_AS_JSON 8 /* introduced in 6.5.1, 2012-09-02 */
 /** Template is used to render a dynamic file name. */
 #define OMSR_TPL_AS_DYNAFILE 16
-/* next option is 32, 64, ... */
+/** Template must use SQL_ESCAPE, which also escapes backslashes. */
+#define OMSR_RQD_TPL_OPT_SQL_BACKSLASH 32
+/* next option is 64, 128, ... */
 
 struct omodStringRequest_s { /* strings requested by output module for 
doAction() */
     int iNumEntries; /* number of array entries for data elements below */
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index 5853837d8..30a225b63 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -253,7 +253,7 @@ static uchar template_FullJSONFmt[] =
 static uchar template_StdClickHouseFmt[] =
     "\"INSERT INTO rsyslog.SystemEvents (severity, facility, "
     "timestamp, hostname, tag, message) VALUES (%syslogseverity%, 
%syslogfacility%, "
-    "'%timereported:::date-unixtimestamp%', '%hostname%', '%syslogtag%', 
'%msg%')\",STDSQL";
+    "'%timereported:::date-unixtimestamp%', '%hostname%', '%syslogtag%', 
'%msg%')\",SQL";
 static uchar template_StdOmSenderTrack_senderid[] =
     "\"%fromhost-ip%\""; /* default template for omsendertrack "senderid" 
parameter*/
 static uchar template_PerSourceKey[] = "\"%hostname%\""; /* default template 
for per-source ratelimiting */

Reply via email to