rsyslog has fixed a local integrity issue in imuxsock plain
trusted-property annotation.
When annotation is enabled in plain mode, a local process can include
field delimiters in its process name or executable path. The resulting
annotation can contain duplicate-looking identity fields. A downstream
consumer that treats these unescaped fields as kernel-derived identity
may misattribute the sender.
The issue requires Linux, a writable affected Unix log socket,
imuxsock annotation enabled, and Annotate="on" with
ParseTrusted="off". Annotation is disabled by default.
ParseTrusted="on" JSON output is not affected.
Severity: Low, CVSS 3.1 3.3 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N)
CWE: CWE-117
Affected upstream versions: >= 5.9.4
Fixed upstream version: 2026-11-17 daily stable
CVE: CVE-2026-129838
Advisory:
https://github.com/rsyslog/rsyslog/security/advisories/GHSA-w259-2hhm-9vr7
The fix quotes and escapes string-valued plain trusted properties and
bounds buffer growth for the encoded representation. As workarounds,
disable imuxsock annotation where it is unnecessary or, where
operationally compatible, use ParseTrusted="on".
The attached source-only patch is from private PR #16 exact head
b513ab996aced2db5271b7255a98caab4a7f8a21. Patch SHA-256:
09c7cb64f24e7a5ae47141094f78ecabdd706b7cd0db120685ffdd1cf76faa76.
Credit: discovered by Rainer Gerhards during an internal AI-assisted
review of imuxsock using Claude Code.
Disclosure: 2026-11-17 16:00 UTC / 17:00 CET / 11:00 EST.
Rainer Gerhards
rsyslog lead maintainer
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index e6d1ca73a8..56ca8a02b8 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -900,29 +900,40 @@ static rsRetVal getTrustedExe(struct ucred *cred, uchar *buf, size_t lenBuf, int
* It is assumed the output buffer is large enough. Returns the number of
* characters added.
*/
-static int copyescaped(uchar *dstbuf, uchar *inbuf, int inlen) {
+static size_t copyescaped(uchar *dstbuf, const uchar *inbuf, const int inlen) {
+ static const uchar hex[] = "0123456789abcdef";
int iDst, iSrc;
*dstbuf = '"';
- for (iDst = 1, iSrc = 0; iSrc < inlen; ++iDst, ++iSrc) {
+ for (iDst = 1, iSrc = 0; iSrc < inlen; ++iSrc) {
if (inbuf[iSrc] == '"' || inbuf[iSrc] == '\\') {
dstbuf[iDst++] = '\\';
+ dstbuf[iDst++] = inbuf[iSrc];
+ } else if (iscntrl((unsigned char)inbuf[iSrc])) {
+ dstbuf[iDst++] = '\\';
+ dstbuf[iDst++] = 'x';
+ dstbuf[iDst++] = hex[inbuf[iSrc] >> 4];
+ dstbuf[iDst++] = hex[inbuf[iSrc] & 0x0f];
+ } else {
+ dstbuf[iDst++] = inbuf[iSrc];
}
- dstbuf[iDst] = inbuf[iSrc];
}
dstbuf[iDst++] = '"';
- return iDst;
+ return (size_t)iDst;
}
-static size_t escapedLen(uchar *inbuf, int inlen) {
+static size_t escapedLen(const uchar *inbuf, const int inlen) {
size_t len = 2; /* surrounding quotes */
for (int i = 0; i < inlen; ++i) {
if (inbuf[i] == '"' || inbuf[i] == '\\') {
+ len += 2;
+ } else if (iscntrl((unsigned char)inbuf[i])) {
+ len += 4; /* \xNN */
+ } else {
++len;
}
- ++len;
}
return len;
}
@@ -943,6 +954,68 @@ static rsRetVal appendTrustedProp(
}
+static rsRetVal ensureTrustedPropSpace(
+ uchar **const dst, size_t *const dstLen, uchar *const stackDst, const size_t used, const size_t extra) {
+ uchar *newDst;
+ size_t needed;
+ size_t newLen;
+ DEFiRet;
+
+ if (extra > (size_t)-1 - used) {
+ ABORT_FINALIZE(RS_RET_ERR);
+ }
+ needed = used + extra;
+ if (needed <= *dstLen) {
+ FINALIZE;
+ }
+
+ newLen = *dstLen;
+ while (newLen < needed) {
+ if (newLen > (size_t)-1 / 2) {
+ newLen = needed;
+ } else {
+ newLen *= 2;
+ }
+ }
+
+ if (*dst == stackDst) {
+ CHKmalloc(newDst = malloc(newLen));
+ memcpy(newDst, *dst, used);
+ } else {
+ CHKmalloc(newDst = realloc(*dst, newLen));
+ }
+ *dst = newDst;
+ *dstLen = newLen;
+
+finalize_it:
+ RETiRet;
+}
+
+
+static rsRetVal appendEscapedTrustedProp(uchar **const dst,
+ size_t *const dstLen,
+ uchar *const stackDst,
+ size_t *const offs,
+ const uchar *const name,
+ const size_t nameLen,
+ const uchar *const value,
+ const int valueLen) {
+ size_t escaped;
+ DEFiRet;
+
+ escaped = escapedLen(value, valueLen);
+ if (nameLen > (size_t)-1 - escaped || nameLen + escaped > (size_t)-1 - 2) {
+ ABORT_FINALIZE(RS_RET_ERR);
+ }
+ CHKiRet(ensureTrustedPropSpace(dst, dstLen, stackDst, *offs, nameLen + escaped + 2));
+ CHKiRet(appendTrustedProp(*dst, *dstLen, offs, name, nameLen));
+ *offs += copyescaped(*dst + *offs, value, valueLen);
+
+finalize_it:
+ RETiRet;
+}
+
+
/* submit received message to the queue engine
* We now parse the message according to expected format so that we
* can also mangle it if necessary.
@@ -1055,22 +1128,17 @@ static rsRetVal SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *
} else {
uchar msgbuf[8192];
uchar *pmsgbuf = msgbuf;
- const size_t trustedPropBufLen = sizeof(propBuf) - 1;
- const size_t trustedPropMaxExtra = 3 + /* " @[" */
- 96 + /* _PID/_UID/_GID tags plus maximum decimal values */
- 7 + trustedPropBufLen + /* _COMM= */
- 6 + trustedPropBufLen + /* _EXE= */
- 10 + 2 + 2 * trustedPropBufLen + /* _CMDLINE= plus escaped value */
- 2; /* closing bracket and NUL */
+ const size_t trustedPropFixedExtra = 3 + /* " @[" */
+ 96 + /* _PID/_UID/_GID tags plus maximum decimal values */
+ 2; /* closing bracket and NUL */
size_t msgbuf_size = sizeof(msgbuf);
size_t toffs; /* offset for trusted properties */
- size_t escaped;
- if ((size_t)lenRcv > (size_t)-1 - trustedPropMaxExtra) {
+ if ((size_t)lenRcv > (size_t)-1 - trustedPropFixedExtra) {
ABORT_FINALIZE(RS_RET_ERR);
}
- if ((size_t)lenRcv + trustedPropMaxExtra > sizeof(msgbuf)) {
- msgbuf_size = (size_t)lenRcv + trustedPropMaxExtra;
+ if ((size_t)lenRcv + trustedPropFixedExtra > sizeof(msgbuf)) {
+ msgbuf_size = (size_t)lenRcv + trustedPropFixedExtra;
CHKmalloc(pmsgbuf = malloc(msgbuf_size));
}
@@ -1090,30 +1158,25 @@ static rsRetVal SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *
}
if (getTrustedProp(cred, "comm", propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) {
- if ((iRet = appendTrustedProp(pmsgbuf, msgbuf_size, &toffs, (uchar *)" _COMM=", 7)) != RS_RET_OK ||
- (iRet = appendTrustedProp(pmsgbuf, msgbuf_size, &toffs, propBuf, (size_t)lenProp)) != RS_RET_OK) {
+ if ((iRet = appendEscapedTrustedProp(&pmsgbuf, &msgbuf_size, msgbuf, &toffs, (uchar *)" _COMM=", 7,
+ propBuf, lenProp)) != RS_RET_OK) {
if (pmsgbuf != msgbuf) free(pmsgbuf);
FINALIZE;
}
}
if (getTrustedExe(cred, propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) {
- if ((iRet = appendTrustedProp(pmsgbuf, msgbuf_size, &toffs, (uchar *)" _EXE=", 6)) != RS_RET_OK ||
- (iRet = appendTrustedProp(pmsgbuf, msgbuf_size, &toffs, propBuf, (size_t)lenProp)) != RS_RET_OK) {
+ if ((iRet = appendEscapedTrustedProp(&pmsgbuf, &msgbuf_size, msgbuf, &toffs, (uchar *)" _EXE=", 6,
+ propBuf, lenProp)) != RS_RET_OK) {
if (pmsgbuf != msgbuf) free(pmsgbuf);
FINALIZE;
}
}
if (getTrustedProp(cred, "cmdline", propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) {
- if ((iRet = appendTrustedProp(pmsgbuf, msgbuf_size, &toffs, (uchar *)" _CMDLINE=", 10)) != RS_RET_OK) {
+ if ((iRet = appendEscapedTrustedProp(&pmsgbuf, &msgbuf_size, msgbuf, &toffs, (uchar *)" _CMDLINE=", 10,
+ propBuf, lenProp)) != RS_RET_OK) {
if (pmsgbuf != msgbuf) free(pmsgbuf);
FINALIZE;
}
- escaped = escapedLen(propBuf, lenProp);
- if (escaped > msgbuf_size || toffs > msgbuf_size - escaped) {
- if (pmsgbuf != msgbuf) free(pmsgbuf);
- ABORT_FINALIZE(RS_RET_ERR);
- }
- toffs += (size_t)copyescaped(pmsgbuf + toffs, propBuf, lenProp);
}
/* finalize string */