Repository navigation
Conversation
infix-syslog:log RPC for injecting messages in the system log
infix-syslog:log RPC for injecting messages in the system log
mattiaswal
left a comment
There was a problem hiding this comment.
Security review of the new log RPC. Verified against libyang (yanglint) with the exact type definitions from this PR, and against the sysklogd 2.7.2 sources Infix ships. Details inline; summary ranked by severity:
- High: format string injection via
msgid. libsyslog'svsyslogp_r()concatenatesmsgidinto the printf format it hands tovsnprintf(), and the pattern[!-~]+allows%. Runs inside confd as root. - Medium: log line forgery via
structured-data/param/value. Control characters are not escaped, syslogd does not sanitize SD (only MSG), andfmt5424writes it verbatim to RFC 5424 files and remote forwarding. - Medium: unbounded SD is truncated in libsyslog's 2048-byte buffer, after which syslogd's RFC 5424 parser drops the whole message silently.
- Medium (design): any user with
execrights (factory NACM:exec-default permit) can forge entries tagged as any daemon, inauth/authpriv, or atemergencyseverity (walled to all ttys and/dev/console). Onlykernis neutralized by syslogd. - Low: no rate limiting; libsyslog's
sendto()is blocking and confd's RPC callback isSR_SUBSCR_NO_THREAD. - Low: default app-name from
sr_session_get_orig_name()is client-controlled.
What I checked and found fine: the sd-name typedef matches RFC 5424 exactly (rejects =, ], ", SP); sd_build() length arithmetic is correct and sysrepo validates mandatory/key leaves before the callback; ASCII control characters in message are rejected by libyang (C0 except TAB/LF/CR) or neutralized by syslogd (LF to space, others to ^X); the klish script quoting and the rpc/copy changes are sound.
Note that -8 on syslogd disables C1 masking, so UTF-8 encoded C1 controls (U+0085, U+009B), U+2028 and bidi overrides in message reach log files and show log untouched. Low severity, mentioned for completeness.
|
Didn't find anything when reviewing but i was scared about something like #1643 (comment) so i let claude get a round of this. This i feel is crutial, other it looks fine. |
Agreed, will have a look at it over the weekend, thanks! 🙇♂️ |
Add an infix-syslog:log RPC that hands a message to the local syslog daemon. The full RFC 5424 header is exposed: severity, facility, app-name, msgid, and structured data. Defaults follow logger(1), notice severity, with app-name defaulting to the user name reported by the calling client. The message is time stamped on arrival and goes through the regular /syslog filtering and forwarding rules, so where it ends up is decided by the device configuration, not the caller. The handler uses syslogp_r() from the sysklogd libsyslog, which passes msgid and structured data through and sets the tag per call without touching confd's own openlog() identity. The callback's event session runs as confd, so the calling user is taken from the event originator: netopeer2 pushes it as originator data, the CLI sets it as originator name. RESTCONF conveys no caller at all, since sysrepo keeps the NACM user in the client process, so the tag is left at NILVALUE rather than naming the daemon's own user. Messages are logged with the user facility, the RPC offers no way to select one: a caller-selected facility would let messages land among the records written by system services, e.g., auth. For the same reason structured data is limited to private SD-IDs, the short form is reserved for identifiers registered with IANA, like origin, which collectors read as provenance. The RPC is nacm:default-deny-all since the remaining header fields, the tag included, are caller-supplied and unverified. Input is bounded to what libsyslog's 2048 byte packet buffer holds, oversized calls are rejected rather than silently truncated, msgid may not contain '%', which libsyslog would treat as a printf conversion, and control characters are kept out of structured data, which syslogd does not sanitize. Fixes #1639 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Front-end to the infix-syslog:log RPC. Optional severity, facility, and msgid keywords precede the message, which is the rest of the line: admin@example:/> log severity warning msgid test-start Test 42 starting Two fixes to the rpc tool the command is built on. It now sets the session originator name to the calling user, like klish-plugin-sysrepo, so the RPC can default app-name to the user. And it only splits comma-separated values for leaf-lists, previously any leaf value with a comma became two instances and the RPC failed: $ rpc /infix-syslog:log message "Kilroy was here, again" Issue #1639 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Wrap the infix-syslog:log RPC so tests can leave markers in a DUT's system log over the management API instead of SSH and logger(1). Facility names are module-qualified in the helper, and structured data is given as a dict of dicts to keep call sites short. The RESTCONF backend's call_dict() only tracked coverage and returned without sending anything, so RPCs with input silently did nothing over RESTCONF. POST to /restconf/operations/MODULE:NAME with the input wrapped per RFC 8040, like call_action() does. Convert the tests that logged via SSH. The remote and hostname_filter tests keep using logger(1), they deliberately exercise the remote client path. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Log to an RFC 5424 formatted file and check app-name, msgid, and structured data land in the header, and that a bare message gets the default app-name with empty msgid and structured data. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The documented way to force a transport had no effect, the tests kept
picking one pseudo-randomly:
make INFAMY_EXTRA_ARGS="--transport=restconf" TESTS=... test
The env script appended -o="$INFAMY_EXTRA_ARGS" to its command, which
reached 9pm while the make recipe called it directly. Since the recipe
was wrapped in sh -c '...' to run the report tool in the container, the
appended argument became $0 of that shell script instead.
Fold the extra arguments into INFAMY_ARGS, which Infamy prepends to
every test's argv, so the override reaches the tests regardless of how
9pm is invoked.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
Ping @mattiaswal: rebased on latest |
|
Verified fixed
Also closed: the literal "netopeer2" tag fallback now yields -. Unchanged, acceptable with admin-only exec
Verdict: no open findings above Low. Safe to merge from the security side. |
Description
Test systems and scripts have had no clean way to leave a mark in a device's log, short of SSH and
logger(1). This adds an RPC that hands a message to the local syslog daemon, exposing the full RFC 5424 header: severity, app-name, msgid, and structured data. Defaults followlogger,user.notice, with app-name defaulting to the calling user. Messages are time stamped on arrival and follow the configured/syslogfiltering and forwarding rules, so the device decides where they end up, not the caller.infix-syslog.yangrevision with thelogRPClog [severity S] [msgid M] MESSAGE.target.log()helper, four tests converted from SSH +loggersyslog/rpc_logcase verifying header fields and defaultsChecklist
Tick relevant boxes, this PR is-a or has-a: