Skip to content

Commit 42590a9

Browse files
[AUTO-CHERRYPICK] [AUTO-PR] azure-core/azurelinux:cve/sudo/2025-32462_2025-32463 - branch main (#14198)
Co-authored-by: Pawel Winogrodzki <[email protected]>
1 parent 90550b8 commit 42590a9

File tree

5 files changed

+3757
-8
lines changed

5 files changed

+3757
-8
lines changed

SPECS/sudo/CVE-2025-32462.patch

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Local Privilege Escalation via host option
2+
3+
Sudo's host (`-h` or `--host`) option is intended to be used in
4+
conjunction with the list option (`-l` or `--list`) to list a user's
5+
sudo privileges on a host other than the current one. However, due
6+
to a bug it was not restricted to listing privileges and could be
7+
used when running a command via `sudo` or editing a file with
8+
`sudoedit`. Depending on the rules present in the sudoers file
9+
this could allow a local privilege escalation attack.
10+
11+
## Sudo versions affected:
12+
13+
Sudo versions 1.8.8 to 1.9.17 inclusive are affected.
14+
15+
## CVE ID:
16+
17+
This vulnerability has been assigned
18+
[CVE-2025-32462](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-32462)
19+
in the [Common Vulnerabilities and Exposures](https://cve.mitre.org/) database.
20+
21+
## Details:
22+
23+
The intent of sudo's `-h` (`--host`) option is to make it possible
24+
to list a user's sudo privileges for a host other than the current
25+
one. It was only intended be used with in conjunction with the
26+
`-l` (`--list`) option.
27+
28+
The bug effectively makes the hostname portion of a sudoers rule
29+
irrelevant since the user can set the host to be used when evaluating
30+
the rules themselves. A user must still be listed in the sudoers
31+
file, but they do not needed to have an entry for the current host.
32+
33+
For example, given the sudoers rule:
34+
35+
``` plain
36+
alice cerebus = ALL
37+
```
38+
39+
user __alice__ would be able to run `sudo -h cerebus id` on any host,
40+
not just _cerebus_. For example:
41+
42+
``` plain
43+
alice@hades$ sudo -l
44+
Sorry, user alice may not run sudo on hades.
45+
46+
alice@hades$ sudo -l -h cerebus
47+
User alice may run the following commands on cerebus:
48+
(root) ALL
49+
50+
alice@hades$ sudo -h cerebus id
51+
uid=0(root) gid=0(root) groups=0(root)
52+
```
53+
54+
## Impact:
55+
56+
Sudoers files that include rules where the host field is not the
57+
current host or _ALL_ are affected. This primarily affects sites
58+
that use a common sudoers file that is distributed to multiple
59+
machines. Sites that use LDAP-based sudoers (including SSSD) are
60+
similarly impacted.
61+
62+
For example, a sudoers rule such as:
63+
64+
``` plain
65+
bob ALL = ALL
66+
```
67+
68+
is not affected since the host _ALL_ already matches any hosts,
69+
but a rule like:
70+
71+
``` plain
72+
alice cerebus = ALL
73+
```
74+
75+
could allow user __alice__ to run any command even if the current
76+
host is not _cerebus_.
77+
78+
## Fix:
79+
80+
The bug is fixed in sudo 1.9.17p1.
81+
82+
## Credit:
83+
84+
Thanks to Rich Mirch from Stratascale Cyber Research Unit (CRU) for
85+
reporting and analyzing the bug.
86+
87+
diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c
88+
index 70a0c1a52..ad2fa2f61 100644
89+
--- a/plugins/sudoers/sudoers.c
90+
+++ b/plugins/sudoers/sudoers.c
91+
@@ -350,6 +350,18 @@ sudoers_check_common(struct sudoers_context *ctx, int pwflag)
92+
time_t now;
93+
debug_decl(sudoers_check_common, SUDOERS_DEBUG_PLUGIN);
94+
95+
+ /* The user may only specify a host for "sudo -l". */
96+
+ if (!ISSET(ctx->mode, MODE_LIST|MODE_CHECK)) {
97+
+ if (strcmp(ctx->runas.host, ctx->user.host) != 0) {
98+
+ log_warningx(ctx, SLOG_NO_STDERR|SLOG_AUDIT,
99+
+ N_("user not allowed to set remote host for command"));
100+
+ sudo_warnx("%s",
101+
+ U_("a remote host may only be specified when listing privileges."));
102+
+ ret = false;
103+
+ goto done;
104+
+ }
105+
+ }
106+
+
107+
/* If given the -P option, set the "preserve_groups" flag. */
108+
if (ISSET(ctx->mode, MODE_PRESERVE_GROUPS))
109+
def_preserve_groups = true;

0 commit comments

Comments
 (0)