Repository navigation
handle_winsize, handle_exit: reject negative values from the client - #603
Merged
Merged
Conversation
millert
requested changes
Nov 24, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
I don't think the comments add value here. Can you remove those and just include the range checks?
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.
iefa-m
force-pushed
the
logsrvd-negative-numbers
branch
from
November 25, 2026 07:27
a3b3a8f to
b7c89ee
Compare
Contributor
Author
|
Fair enough, dropped both comments and left the existing ones alone, so the diff is just the two range checks now. Rebuilt and make check still passes. |
millert
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handle_winsize()andhandle_exit()validate the other fields of their messages, the delay withvalid_timespec()and the signal name against an allowlist, but not the int32 numbers.store_winsize_local()writes the client's rows and cols into the timing file with%dandstore_exit_info_json()writesexit_valueintolog.json, and neither value can be read back when it is negative:iolog_parse_timing()refuses a negative lines or cols field andjson_store_exit_value()refuses an exit value below zero, which fails the wholelog.json. A client can therefore make its recorded session unreplayable from a record of its choosing, andsudo_logsrvdcan no longer resume that log either; the sudoers I/O plugin cannot produce such a record locally becausesudoers_io_change_winsize_local()formats it with%u.The check belongs in the message handlers next to the existing field validation rather than in each writer, since that covers the local, relay and journal back ends. Negative is the only range worth rejecting here because both readers accept 0 through
INT_MAX.Repro: feeding the exact bytes the two writers emit back through
iolog_parse_timing()andeventlog_json_read()/eventlog_json_parse(),5 0.000000000 -1 80and"exit_value": -1are both refused.make checkpasses.