Skip to content

Commit 64421ac

Browse files
committed
handle_exit: validate signal name before it is logged
If the command exited due to a signal, restrict the specified signal name to a string of no more than 10 upper case ASCII characters, '+', '-', or digits. Found by Pedro Henrique de Almeida Silva of the Stack Security Intelligence Research Team
1 parent b3ad2f9 commit 64421ac

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

logsrvd/logsrvd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,20 @@ handle_exit(const ExitMessage *msg, const uint8_t *buf, size_t len,
606606
closure->errstr = _("invalid ExitMessage");
607607
debug_return_bool(false);
608608
}
609+
if (msg->signal[0] != '\0') {
610+
/*
611+
* We do not know the list of valid signals for the client
612+
* system but we can restrict the value to a small string
613+
* of uppercase ascii characters, '+', '-', and digits.
614+
*/
615+
size_t siglen = strlen(msg->signal);
616+
if (siglen > 10 || strspn(msg->signal,
617+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ+-0123456789") != siglen) {
618+
sudo_warnx(U_("%s: %s"), source, U_("invalid ExitMessage"));
619+
closure->errstr = _("invalid ExitMessage");
620+
debug_return_bool(false);
621+
}
622+
}
609623
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: received ExitMessage from %s",
610624
source, __func__);
611625

0 commit comments

Comments
 (0)