From b7c89ee210cbf43ed798dc6e330db519be56d0d1 Mon Sep 17 00:00:00 2001 From: iefa m Date: Wed, 25 Nov 2026 12:57:29 +0530 Subject: [PATCH] handle_winsize, handle_exit: reject negative values from the client handle_winsize() and handle_exit() check the other fields of their messages but not the int32 numbers, and store_winsize_local() writes rows and cols into the timing file with "%d" while store_exit_info_json() writes exit_value into log.json. A client can therefore store values that sudo will not read back: iolog_parse_timing() rejects a negative lines or cols field and json_store_exit_value() rejects an exit value below zero, which fails the whole log.json. The session then stops being replayable at that record and sudo_logsrvd can no longer resume the log. Reject a negative rows, cols or exit value where the rest of each message is already validated, which covers the local, relay and journal back ends. --- logsrvd/logsrvd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/logsrvd/logsrvd.c b/logsrvd/logsrvd.c index 7b5cfc5667..ef9c6cc696 100644 --- a/logsrvd/logsrvd.c +++ b/logsrvd/logsrvd.c @@ -601,7 +601,7 @@ handle_exit(const ExitMessage *msg, const uint8_t *buf, size_t len, * The run_time field is optional and will not be present * when sending old, pre-JSON I/O logs via sudo_sendlog. */ - if (msg == NULL) { + if (msg == NULL || msg->exit_value < 0) { sudo_warnx(U_("%s: %s"), source, U_("invalid ExitMessage")); closure->errstr = _("invalid ExitMessage"); debug_return_bool(false); @@ -800,7 +800,8 @@ handle_winsize(const ChangeWindowSize *msg, const uint8_t *buf, size_t len, } /* Check that message is valid. */ - if (msg == NULL || !valid_timespec(msg->delay)) { + if (msg == NULL || !valid_timespec(msg->delay) || msg->rows < 0 || + msg->cols < 0) { sudo_warnx(U_("%s: %s"), source, U_("invalid ChangeWindowSize")); closure->errstr = _("invalid ChangeWindowSize"); debug_return_bool(false);