Skip to content

Commit d530367

Browse files
committed
Only allow a remote host to be specified when listing privileges.
This fixes a bug where a user with sudoers privileges on a different host could execute a command on the local host, even if the sudoers file would not otherwise allow this. CVE-2025-32462 Reported by Rich Mirch @ Stratascale Cyber Research Unit (CRU).
1 parent 51c3488 commit d530367

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugins/sudoers/sudoers.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,18 @@ sudoers_check_common(struct sudoers_context *ctx, int pwflag)
350350
time_t now;
351351
debug_decl(sudoers_check_common, SUDOERS_DEBUG_PLUGIN);
352352

353+
/* The user may only specify a host for "sudo -l". */
354+
if (!ISSET(ctx->mode, MODE_LIST|MODE_CHECK)) {
355+
if (strcmp(ctx->runas.host, ctx->user.host) != 0) {
356+
log_warningx(ctx, SLOG_NO_STDERR|SLOG_AUDIT,
357+
N_("user not allowed to set remote host for command"));
358+
sudo_warnx("%s",
359+
U_("a remote host may only be specified when listing privileges."));
360+
ret = false;
361+
goto done;
362+
}
363+
}
364+
353365
/* If given the -P option, set the "preserve_groups" flag. */
354366
if (ISSET(ctx->mode, MODE_PRESERVE_GROUPS))
355367
def_preserve_groups = true;

0 commit comments

Comments
 (0)