A JSON escaping defect in rsyslog string/list templates with
option.json="on" affects releases beginning with v8.23.0. When a field
value consists only of double quotes and/or backslashes,
runtime/template.c can return from its JSON precheck without escaping
it. A template that inserts the field into a JSON string can then emit
malformed JSON. A sender must control a field used by an affected
template; remote unauthenticated access is deployment dependent.

The reproduced effect is malformed output and rejection of the
affected record by a strict JSON parser. We have not established
injection, neighboring-record loss, or batch dropping by a named
downstream service. The separate property format="json" path was a
control and was not affected in our test.

Advisory: 
https://github.com/rsyslog/rsyslog/security/advisories/GHSA-cg8j-rwxh-vrg3
Severity: Medium, CVSS 3.1 5.3 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N)
CWE: CWE-116
Affected upstream versions: >= 8.23.0
Fixed upstream version: 2026-11-17 daily stable
CVE: CVE-2026-129839
Credit: Manyo9

The source fix changes the JSON precheck in runtime/template.c so that
it stops at the first quote or backslash and lets the existing
replacement loop escape the value.

The source-only patch is attached as source-only-candidate-e422479031.patch.
Patch SHA-256: 32e5deb04929d7c5d014cf8d5aa9cd0a9a4dbc93f02229a703ab8e8a93708c21.

Disclosure: 2026-11-17 16:00 UTC / 17:00 CET / 11:00 EST.

Rainer Gerhards
rsyslog lead maintainer
diff --git a/runtime/template.c b/runtime/template.c
index 14e38421d..7f0f4272b 100644
--- a/runtime/template.c
+++ b/runtime/template.c
@@ -1171,7 +1171,7 @@ rsRetVal doEscape(uchar **pp, rs_size_t *pLen, unsigned short *pbMustBeFreed, in
     else if (mode == SQL_ESCAPE)
         for (p = *pp; *p && *p != '\'' && *p != '\\'; ++p);
     else if (mode == JSON_ESCAPE)
-        for (p = *pp; *p && (*p == '"' || *p == '\\'); ++p);
+        for (p = *pp; *p && *p != '"' && *p != '\\'; ++p);
     /* when we get out of the loop, we are either at the
      * string terminator or the first character to escape */
     if (p && *p == '\0') FINALIZE; /* nothing to do in this case! */

Reply via email to