Credit: Reported by @karimabisaad.

rsyslog's imuxsock special parser can write beyond a received
message's raw buffer when replacing the message timestamp with the
system timestamp. A local sender able to write to a directly
accessible imuxsock Unix datagram socket can combine an overlong
invalid PRI with a short timestamp accepted by the permissive RFC3164
parser. The fixed 16-byte in-place rewrite then has insufficient
remaining capacity.

Direct code inspection establishes the out-of-bounds write. The
overwritten bytes derive from the daemon's current local time and a
space, limiting attacker control over the values. A reliable crash or
sustained denial of service in an ordinary, non-sanitized rsyslogd
build has not been demonstrated. The provisional rating is Medium,
CVSS 3.1 5.5 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H). CVE:
CVE-2026-129829.

Affected configuration: imuxsock's special parser with UseSysTimeStamp
on a directly accessible raw Unix socket. The checked supported-v8
affected range is >= 8.1.0. Older v5-v7 releases are not implied safe;
historical branches need specific validation. The planned fixed
version is 2026-11-17 daily stable. Verify actual package availability
separately before stating that a binary release contains the fix.

The attached source-only patch addresses this reported write on the
checked baseline. The full upstream fix includes regression tests and
documentation. Apply or backport it against the exact source version
you maintain. The patch and advisory are available at
https://github.com/rsyslog/rsyslog/security/advisories/GHSA-xrxr-7942-54fr;
check that page and the public rsyslog/rsyslog pull request for
release-specific commits and status.

The timestamp-write source patch is standalone against the checked
baseline. The separate TAG patch must be applied after this patch; the
separate PRI digit hardening patch is not required for this fix.

Coordinated disclosure: 2026-11-17 16:00 UTC (17:00 CET). Planned
fixed-version label: 2026-11-17 daily stable. Actual binary package
availability must be verified separately.

Patch (source only): see the attached .patch file (preserved without
line wrapping).
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index e6d1ca73a..a38f2cab4 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -1141,14 +1141,20 @@ static rsRetVal SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *
         pMsg->msgFlags = pLstn->flags;
     }
 
-    if (pLstn->bUseSpecialParser) {
+    if (pLstn->bUseSpecialParser && priValid) {
         /* this is the legacy "log socket" parser which was written on the assumption
          * that the log socket format would be fixed. While many folks said so, it
          * seems to be different in practice, and this is why we now have choices...
          * rgerhards, 2015-03-03
          */
-        parser.SanitizeMsg(pMsg);
-        lenMsg = pMsg->iLenRawMsg - offs; /* SanitizeMsg() may have changed the size */
+        CHKiRet(parser.SanitizeMsg(pMsg));
+        /* Sanitizing may shorten the raw message. Never reuse a PRI cursor
+         * outside the current representation. */
+        if (offs >= pMsg->iLenRawMsg) {
+            pMsg->msgFlags |= NEEDS_PARSING;
+            goto submit;
+        }
+        lenMsg = pMsg->iLenRawMsg - offs;
         parse = pMsg->pszRawMsg + offs;
         msgSetPRI(pMsg, pri);
         MsgSetAfterPRIOffs(pMsg, priValid ? offs + 1 : 0);
@@ -1172,15 +1178,15 @@ static rsRetVal SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *
                 }
             }
         } else { /* if we pulled the time from the system, we need to update the message text */
-            uchar *tmpParse = parse; /* just to check correctness of TS */
-            if (datetime.ParseTIMESTAMP3339(&dummyTS, &tmpParse, &lenMsg) == RS_RET_OK ||
-                datetime.ParseTIMESTAMP3164(&dummyTS, &tmpParse, &lenMsg, NO_PARSE3164_TZSTRING,
-                                            NO_PERMIT_YEAR_AFTER_TIME) == RS_RET_OK) {
-                /* We modify the message only if it contained a valid timestamp,
-                otherwise we do not touch it at all. */
+            uchar *tmpParse = parse;
+            const int lenAvail = lenMsg;
+            if ((datetime.ParseTIMESTAMP3339(&dummyTS, &tmpParse, &lenMsg) == RS_RET_OK ||
+                 datetime.ParseTIMESTAMP3164(&dummyTS, &tmpParse, &lenMsg, NO_PARSE3164_TZSTRING,
+                                             NO_PERMIT_YEAR_AFTER_TIME) == RS_RET_OK) &&
+                lenAvail >= 16) {
+                /* The fixed-width rewrite must fit in the remaining raw message. */
                 datetime.formatTimestamp3164(&st, (char *)parse, 0);
-                parse[15] = ' '; /* re-write \0 from fromatTimestamp3164 by SP */
-                /* update "counters" to reflect processed timestamp */
+                parse[15] = ' ';
                 parse += 16;
             }
         }
@@ -1200,6 +1206,7 @@ static rsRetVal SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *
         pMsg->msgFlags |= NEEDS_PARSING;
     }
 
+submit:
     MsgSetRcvFrom(pMsg, pLstn->hostName == NULL ? glbl.GetLocalHostNameProp() : pLstn->hostName);
     CHKiRet(MsgSetRcvFromIP(pMsg, pLocalHostIP));
     MsgSetRuleset(pMsg, pLstn->pRuleset);

Reply via email to