既上次对这个罕见的sudo漏洞的复现利用已经过去了几天,陆陆续续各大发行版已经推送了修复补丁,各个安全从业者也复现了漏洞,但似乎除了stratascale并没有人尝试追踪漏洞代码及其成因,虽然有些难度但还是想尝试下
How CVE-2025-32463问题出在sudo的-R功能上
简单来说这个漏洞的是利用了 Sudo 在处理 chroot 选项时的一个缺陷联合nss劫持,即使一个普通用户没有任何 Sudo 权限,他们也可以利用这个漏洞将权限提升到 root
Way 从github clone下代码,在log中可以找到这次修复,show一份出来方便分析
先看到sudoers.c
diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index ad2fa2f61..1a8031740 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -1092,7 +1092,6 @@ init_vars(struct sudoers_context *ctx, char * const envp[]) int set_cmnd_path(struct sudoers_context *ctx, const char *runchroot) { - struct sudoers_pivot pivot_state = SUDOERS_PIVOT_INITIALIZER; const char *cmnd_in; char *cmnd_out = NULL; char *path = ctx->user.path; @@ -1111,13 +1110,7 @@ set_cmnd_path(struct sudoers_context *ctx, const char *runchroot) if (def_secure_path && !user_is_exempt(ctx)) path = def_secure_path; - /* Pivot root. */ - if (runchroot != NULL) { - if (!pivot_root(runchroot, &pivot_state)) - goto error; - } - - ret = resolve_cmnd(ctx, cmnd_in, &cmnd_out, path); + ret = resolve_cmnd(ctx, cmnd_in, &cmnd_out, path, runchroot); if (ret == FOUND) { char *slash = strrchr(cmnd_out, '/'); if (slash != NULL) { @@ -1134,14 +1127,8 @@ set_cmnd_path(struct sudoers_context *ctx, const char *runchroot) else ctx->user.cmnd = cmnd_out; - /* Restore root. */ - if (runchroot != NULL) - (void)unpivot_root(&pivot_state); - debug_return_int(ret); error: - if (runchroot != NULL) - (void)unpivot_root(&pivot_state); free(cmnd_out); debug_return_int(NOT_FOUND_ERROR); } 看的出来入口为
...