diff mbox series

[scarthgap] sudo: Security fix for CVE-2026-96512

Message ID 20261130044832.224300-1-rsangam@mvista.com
State New
Headers show
Series [scarthgap] sudo: Security fix for CVE-2026-96512 | expand

Commit Message

Rohini Sangam Nov. 30, 2026, 4:48 a.m. UTC
Pick patch from [1] and [2] also mentioned at Debian tracker in [3]

[1] https://github.com/sudo-project/sudo/commit/db669167ca599f2a94cd8a4c5fae9e473c81a2fd
[2] https://github.com/sudo-project/sudo/commit/1820a349687522f51023d1ae5925125f59679a8c
[3] https://security-tracker.debian.org/tracker/CVE-2026-96512

Signed-off-by: Rohini Sangam <rsangam@mvista.com>
---
 .../sudo/files/CVE-2026-96512-pre1.patch      | 73 ++++++++++++++++
 .../sudo/files/CVE-2026-96512.patch           | 83 +++++++++++++++++++
 meta/recipes-extended/sudo/sudo_1.9.17p2.bb   |  2 +
 3 files changed, 158 insertions(+)
 create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-96512-pre1.patch
 create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-96512.patch
diff mbox series

Patch

diff --git a/meta/recipes-extended/sudo/files/CVE-2026-96512-pre1.patch b/meta/recipes-extended/sudo/files/CVE-2026-96512-pre1.patch
new file mode 100644
index 0000000000..99d382ab04
--- /dev/null
+++ b/meta/recipes-extended/sudo/files/CVE-2026-96512-pre1.patch
@@ -0,0 +1,73 @@ 
+From db669167ca599f2a94cd8a4c5fae9e473c81a2fd Mon Sep 17 00:00:00 2001
+From: "Todd C. Miller" <Todd.Miller@sudo.ws>
+Date: Sat, 14 Mar 2026 13:13:17 -0600
+Subject: [PATCH] sudo: ignore user-specified TZ environment variable
+
+This avoids potential issues caused by a user-specified timezone
+when running sudo, such as the parsing of NOTBEFORE/NOTAFTER values
+in sudoers.  The TZ variable is still passed to the command being
+run unless blocked by sudoers rules.
+
+Credit:
+- XlabAI Team of Tencent Xuanwu Lab (xlabai@tencent.com)
+- Atuin Automated Vulnerability Discovery Engine
+- Guannan Wang, Zhanpeng Liu, Guancheng Li
+
+CVE: CVE-2026-96512
+Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/db669167ca599f2a94cd8a4c5fae9e473c81a2fd]
+
+Signed-off-by: Rohini Sangam <rsangam@mvista.com>
+---
+ src/sudo.c | 22 +++++++++++++++++++++-
+ 1 file changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/src/sudo.c b/src/sudo.c
+index 0ed0538..e5ff072 100644
+--- a/src/sudo.c
++++ b/src/sudo.c
+@@ -99,6 +99,7 @@ static void sudo_check_suid(const char *path);
+ static char **get_user_info(struct user_details *);
+ static void command_info_to_details(char * const info[],
+     struct command_details *details);
++static void set_time_zone(void);
+ static void gc_init(void);
+ 
+ /* Policy plugin convenience functions. */
+@@ -163,7 +164,8 @@ main(int argc, char *argv[], char *envp[])
+     bindtextdomain(PACKAGE_NAME, LOCALEDIR);
+     textdomain(PACKAGE_NAME);
+ 
+-    (void) tzset();
++    /* Use system time zone, not user-specified. */
++    set_time_zone();
+ 
+     /* Must be done before we do any password lookups */
+ #if defined(HAVE_GETPRPWNAM) && defined(HAVE_SET_AUTH_PARAMETERS)
+@@ -341,6 +343,24 @@ access_denied:
+     return EXIT_FAILURE;
+ }
+ 
++/*
++ * Set the time zone using tzset(3), ignoring the user's TZ
++ * environment variable.  The original value of TZ may still
++ * be present in the command's environment, depending on sudoers.
++ */
++static void
++set_time_zone(void)
++{
++    extern char **environ;
++    char **real_environ = environ;
++    char *empty[] = { NULL };
++
++    /* Use system time zone, not user-specified. */
++    environ = empty;
++    (void) tzset();
++    environ = real_environ;
++}
++
+ int
+ os_init_common(int argc, char *argv[], char *envp[])
+ {
+-- 
+2.44.4
+
diff --git a/meta/recipes-extended/sudo/files/CVE-2026-96512.patch b/meta/recipes-extended/sudo/files/CVE-2026-96512.patch
new file mode 100644
index 0000000000..c3d219b5a2
--- /dev/null
+++ b/meta/recipes-extended/sudo/files/CVE-2026-96512.patch
@@ -0,0 +1,83 @@ 
+From 1820a349687522f51023d1ae5925125f59679a8c Mon Sep 17 00:00:00 2001
+From: "Todd C. Miller" <Todd.Miller@sudo.ws>
+Date: Fri, 28 Aug 2026 16:13:52 -0600
+Subject: [PATCH] Remove TZ from sudo's working environment without modifying
+ envp.
+
+The earlier change to prevent NOTBEFORE/NOTAFTER in sudoers from
+being affected by a user-specified timezone was not effective since
+the mktime() function re-reads the TZ environment variable each
+time it is called.
+
+Reported by Ermenson Junior
+
+CVE: CVE-2026-96512
+Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/1820a349687522f51023d1ae5925125f59679a8c]
+
+Signed-off-by: Rohini Sangam <rsangam@mvista.com>
+---
+ src/sudo.c | 31 ++++++++++++++++++++++++-------
+ 1 file changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/src/sudo.c b/src/sudo.c
+index e5ff072..e099c9b 100644
+--- a/src/sudo.c
++++ b/src/sudo.c
+@@ -344,30 +344,47 @@ access_denied:
+ }
+ 
+ /*
+- * Set the time zone using tzset(3), ignoring the user's TZ
++ * Set the time zone using tzset(3), removing the user's TZ
+  * environment variable.  The original value of TZ may still
+  * be present in the command's environment, depending on sudoers.
+  */
+ static void
+ set_time_zone(void)
+ {
+-    extern char **environ;
+-    char **real_environ = environ;
+-    char *empty[] = { NULL };
+-
+     /* Use system time zone, not user-specified. */
+-    environ = empty;
++    unsetenv("TZ");
+     (void) tzset();
+-    environ = real_environ;
+ }
+ 
+ int
+ os_init_common(int argc, char *argv[], char *envp[])
+ {
++    extern char **environ;
++    int envc;
+ #ifdef STATIC_SUDOERS_PLUGIN
+     preload_static_symbols();
+ #endif
+     gc_init();
++
++    /*
++     * Make a copy of environ[] that is distinct from envp[].
++     * This allows us to remove variables from sudo's environment
++     * while still providing the original envp to the plugins.
++     */
++    for (envc = 0; envp[envc] != NULL; envc++)
++	continue;
++    if (envc != 0) {
++	char **new_env = reallocarray(NULL, sizeof(char *), envc + 1);
++	if (new_env == NULL || !gc_add(GC_PTR, new_env)) {
++	    sudo_fatalx_nodebug(U_("%s: %s"), __func__,
++		U_("unable to allocate memory"));
++	}
++	for (envc = 0; envp[envc] != NULL; envc++)
++	    new_env[envc] = envp[envc];
++	new_env[envc] = NULL;
++	environ = new_env;
++    }
++
+     return 0;
+ }
+ 
+-- 
+2.44.4
+
diff --git a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
index 69bd654d08..88bcd7880b 100644
--- a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
+++ b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
@@ -4,6 +4,8 @@  SRC_URI = "https://www.sudo.ws/dist/sudo-${PV}.tar.gz \
            ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
            file://0001-sudo.conf.in-fix-conflict-with-multilib.patch \
            file://CVE-2026-35535.patch \
+           file://CVE-2026-96512-pre1.patch \
+           file://CVE-2026-96512.patch \
            "
 
 PAM_SRC_URI = "file://sudo.pam"