GHSA-pw82-9r22-hjqg
Summary rsyslog escapes control characters in received messages ($EscapeControlCharactersOnReceive, on by default) in…
- Scores
- UnknownNo source reports a CVSS or EPSS score yet.
- Exploitation
- UnknownNo source reports exploitation yet.
- Listed fix
- None listedNo source lists a fixed version in its version data.Check the description and references.
Overview
Summary
rsyslog escapes control characters in received messages
($EscapeControlCharactersOnReceive, on by default) in the message parser
(SanitizeMsg()). imklog builds its messages itself and does not mark them for
parsing, so this step never runs for kernel messages. Every byte the kernel
prints, except LF (line separator) and NUL (the kernel never emits it), goes
into the message text unchanged.
Through /proc/kmsg the kernel prints strings chosen by unprivileged
processes without escaping (only /dev/kmsg escapes them), above all the
task name (comm, 15 bytes, prctl(PR_SET_NAME) or the basename of the
executed file). A program named ESC[31mRED CR that crashes therefore puts a
raw ESC sequence and a carriage return into every rsyslog output that
receives kernel messages, for example /var/log/kern.log and
/var/log/syslog. Displaying such a file in a terminal executes the escape
sequences (colour, cursor movement, screen clearing, title changes, and
whatever else the terminal emulator interprets); CR lets the rest of a line
overwrite the start of the displayed line.
The same happens in every other output that writes %msg% raw, including
:omusrmsg: (wall) and forwarding.
Affected configuration
module(load="imklog")with default settings, reading/proc/kmsg. Loaded by default in Debian/Ubuntu-style configurations.- Any action that writes
%msg%without a template option such asescape-cc,space-ccordrop-cc; the built-in file, forward and wall templates do not escape. - The kernel must print the attacker's string: for the segfault report
debug.exception-trace=1(default), rate limited by the kernel (printk_ratelimit, by default 10 messages per 5 seconds). - Attacker: any local user who can run a program. Writing to
/dev/kmsgis not needed and not possible (mode 0644 root:root).
Details
Source at a6c1f4023d (main, after 8.2610.0):
plugins/imklog/imklog.c:166-183enqMsg():msgConstruct()(flags 0, i.e. noNEEDS_PARSING),MsgSetRawMsgWOSize(pMsg, msg),MsgSetMSGoffs(pMsg, 0), tag and PRI set directly.tools/rsyslogd.c:841:parser.ParseMsg()only for messages withNEEDS_PARSING;runtime/parser.c:729SanitizeMsg()is only called from there. Kernel messages therefore never reach the escaping.runtime/rsconf.c:222WallFmtandtools/omusrmsg.c:308: the wall text is"\r\n\7Message from syslogd@... \r\n %syslogtag%%msg%\n\r"and is written to each terminal unchanged.
Reproduction (performed 2026-11-14)
Environment: rsyslog main a6c1f4023d built twice (clang 18 with ASan/UBSan,
and gcc 13 -O2 -D_FORTIFY_SOURCE=2), WSL2 kernel 5.15.167.4.
Kernel output: as an unprivileged user a small program sets its name with
prctl(PR_SET_NAME)toESC [31mRED CRand dereferences NULL. The kernel output was captured withklogctl(SYSLOG_ACTION_READ_ALL), which uses the same formatter as/proc/kmsg(reading/proc/kmsgneeds CAP_SYSLOG). Captured (shown withcat -v):<6>[213394.704515] ^[[31mRED^M[2527574]: segfault at 0 ip ... in segv[...]Replay: rsyslogd with
module(load="imklog" logpath="<fifo>"), upstream default settings, omfile with a plain%msg%template. Output (cat -v):pri=kern.info tag=kernel: msg= ^[[31mRED^M[2527574]: segfault at 0 ...ESC and CR arrive byte for byte. Same with
permitnonkernelfacility="on"and on both builds.Chain with V1 (
permitnonkernelfacility="on"): process name<8>ESC[2JESC[HX(clear screen, cursor home; 15 bytes). Captured kernel line and result:<6>[213531.071662] <8>^[[2J^[[HX[2592902]: segfault at 0 ... pri=user.emerg tag=kernel: msg=^[[2J^[[HX[2592902]: segfault at 0 ...The message matched a
*.emergaction. That action was omfile standing in for:omusrmsg:*; the write to real terminals was not executed.
Impact
Integrity of log files and of what administrators see when they display them. A local unprivileged user can embed terminal control sequences and carriage returns in kernel-tagged log lines: hide or rewrite displayed text, clear the screen, change terminal state, and reach any terminal-emulator handling of escape sequences on the viewing side.
Chained with V1 (permitnonkernelfacility="on" plus a *.emerg :omusrmsg:*
rule), the sequences are written to every logged-in terminal without any
user action, similar to the util-linux wall escape-sequence issue. This
requires that rsyslogd can open the terminals. On stock Ubuntu it cannot:
rsyslogd runs as user syslog (groups syslog, adm, no capabilities)
and terminals are mode 0620 owner/tty, so the broadcast is not delivered
there. It applies where rsyslogd keeps root privileges (upstream default).
With a maxMessageSize below about 1-2 KiB the split-line variant in V1
gives kern.emerg even with permitnonkernelfacility="off".
LF cannot be injected into a single record through /proc/kmsg: the kernel
starts a new prefixed line, which rsyslog logs as a separate kernel message
(see V1). No memory safety impact.
Fix direction
plugins/imklog/imklog.cenqMsg(): escape control characters in the message text, with the same semantics and global settings asSanitizeMsg()(parser.escapeControlCharactersOnReceive, escape prefix, 8-bit and tab handling). Preferably call the parser'sSanitizeMsg()(exported in the parser interface) on the message afterMsgSetRawMsgWOSize()instead of writing a second implementation. This is the only place where imklog creates messages from kernel text, so it covers/proc/kmsg,/dev/klog(BSD) and any configured LogPath.- Apply the same to the split continuation fragments (they go through the
same
enqMsg(), so point 1 covers them once V1's fix keeps them in the normal path). - Regression test: LogPath-based imklog test with ESC, CR, BEL and DEL in the
text; the output must contain the
#oooescapes. - Optional defence in depth (separate decision, not needed for this
advisory):
WallFmt/StdUsrMsgFmtcould useescape-ccfor%syslogtag%and%msg%, since:omusrmsg:writes to terminals.
Workaround until a fix: use %msg:::escape-cc% (or space-cc / drop-cc)
instead of %msg% in the templates of actions that receive kernel messages,
including a custom template for :omusrmsg:.
Affected
Packages 1
| Package | Affected | Fixed |
|---|---|---|
ascender-25Docker Hardened Images:Debian:13 | 25.6.3-0 and later, plus listed versions 25.6.3-125.6.3-1025.6.3-1125.6.3-1225.6.3-2 Show 7 more versionsShow less25.6.3-325.6.3-425.6.3-525.6.3-625.6.3-725.6.3-825.6.3-9 | None listed |
Sources
OSVDHI-3pnf-qbzr-p5mf-admzNo score
## Summary
Summary
rsyslog escapes control characters in received messages
($EscapeControlCharactersOnReceive, on by default) in the message parser
(SanitizeMsg()). imklog builds its messages itself and does not mark them for
parsing, so this step never runs for kernel messages. Every byte the kernel
prints, except LF (line separator) and NUL (the kernel never emits it), goes
into the message text unchanged.
Through /proc/kmsg the kernel prints strings chosen by unprivileged
processes without escaping (only /dev/kmsg escapes them), above all the
task name (comm, 15 bytes, prctl(PR_SET_NAME) or the basename of the
executed file). A program named ESC[31mRED CR that crashes therefore puts a
raw ESC sequence and a carriage return into every rsyslog output that
receives kernel messages, for example /var/log/kern.log and
/var/log/syslog. Displaying such a file in a terminal executes the escape
sequences (colour, cursor movement, screen clearing, title changes, and
whatever else the terminal emulator interprets); CR lets the rest of a line
overwrite the start of the displayed line.
The same happens in every other output that writes %msg% raw, including
:omusrmsg: (wall) and forwarding.
Affected configuration
module(load="imklog")with default settings, reading/proc/kmsg. Loaded by default in Debian/Ubuntu-style configurations.- Any action that writes
%msg%without a template option such asescape-cc,space-ccordrop-cc; the built-in file, forward and wall templates do not escape. - The kernel must print the attacker's string: for the segfault report
debug.exception-trace=1(default), rate limited by the kernel (printk_ratelimit, by default 10 messages per 5 seconds). - Attacker: any local user who can run a program. Writing to
/dev/kmsgis not needed and not possible (mode 0644 root:root).
Details
Source at a6c1f4023d (main, after 8.2610.0):
plugins/imklog/imklog.c:166-183enqMsg():msgConstruct()(flags 0, i.e. noNEEDS_PARSING),MsgSetRawMsgWOSize(pMsg, msg),MsgSetMSGoffs(pMsg, 0), tag and PRI set directly.tools/rsyslogd.c:841:parser.ParseMsg()only for messages withNEEDS_PARSING;runtime/parser.c:729SanitizeMsg()is only called from there. Kernel messages therefore never reach the escaping.runtime/rsconf.c:222WallFmtandtools/omusrmsg.c:308: the wall text is"\r\n\7Message from syslogd@... \r\n %syslogtag%%msg%\n\r"and is written to each terminal unchanged.
Reproduction (performed 2026-11-14)
Environment: rsyslog main a6c1f4023d built twice (clang 18 with ASan/UBSan,
and gcc 13 -O2 -D_FORTIFY_SOURCE=2), WSL2 kernel 5.15.167.4.
Kernel output: as an unprivileged user a small program sets its name with
prctl(PR_SET_NAME)toESC [31mRED CRand dereferences NULL. The kernel output was captured withklogctl(SYSLOG_ACTION_READ_ALL), which uses the same formatter as/proc/kmsg(reading/proc/kmsgneeds CAP_SYSLOG). Captured (shown withcat -v):<6>[213394.704515] ^[[31mRED^M[2527574]: segfault at 0 ip ... in segv[...]Replay: rsyslogd with
module(load="imklog" logpath="<fifo>"), upstream default settings, omfile with a plain%msg%template. Output (cat -v):pri=kern.info tag=kernel: msg= ^[[31mRED^M[2527574]: segfault at 0 ...ESC and CR arrive byte for byte. Same with
permitnonkernelfacility="on"and on both builds.Chain with V1 (
permitnonkernelfacility="on"): process name<8>ESC[2JESC[HX(clear screen, cursor home; 15 bytes). Captured kernel line and result:<6>[213531.071662] <8>^[[2J^[[HX[2592902]: segfault at 0 ... pri=user.emerg tag=kernel: msg=^[[2J^[[HX[2592902]: segfault at 0 ...The message matched a
*.emergaction. That action was omfile standing in for:omusrmsg:*; the write to real terminals was not executed.
Impact
Integrity of log files and of what administrators…
- Record
DHI-3pnf-qbzr-p5mf-admz- Updated
- 2026-12-04
The JSON record also has the rest of 1 source description.
History
Recorded by Every CVE
| Day | Changed | Sources |
|---|---|---|
| Affected packages | OSV | |
| First indexed | OSV |
Upstream dates may differ.