sudo: fix CVE-2026-82474
PATCH 1/1 sudo: fix CVE-2026-82474
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
The recipe enables Linux intercept support. Check execveat commands and log subcommands instead of allowing this syscall unconditionally. Resolve directory file descriptors and AT_EMPTY_PATH to paths for sudoers policy checks.
Apply prerequisites [3] and [4] for proc_read_link() and fexecve paths. Include follow-ups [5] and [6] to reject failed pathname rewrites and correct relative-path moves. Keep the upstream source changes intact.
[1] https://github.com/sudo-project/sudo/commit/71fbe42dcd5a1c8f799540583a2dfb2ae6221edf
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-82474
[3] https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575
[4] https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182
[5] https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd
[6] https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512e
--- .../files/CVE-2026-82474-dependent_p1.patch | 94 +++ .../files/CVE-2026-82474-dependent_p2.patch | 34 + .../files/CVE-2026-82474-regression_p1.patch | 39 ++ .../files/CVE-2026-82474-regression_p2.patch | 33 + .../sudo/files/CVE-2026-82474.patch | 617 ++++++++++++++++++ meta/recipes-extended/sudo/sudo_1.9.17p2.bb | 5 + 6 files changed, 822 insertions(+) create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474.patch
meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patch new file +94 -0
@@ -0,0 +1,94 @@ +From 1a312af6348594df371e6088aeed99685977f575 Mon Sep 17 00:00:00 2001 +From: "Todd C. Miller" <[email protected]> +Date: Thu, 19 Mar 2026 13:57:53 -0600 +Subject: [PATCH] get_execve_info: read /proc/self/fd/N link for pathname + +When fexecve(3) is used to execute a command and the kernel doesn't +support execveat(2), glibc will use /proc/self/fd/N for the execve(2) +pathname. We need to resolve this link to the actual pathname used +for intercept and log_subcmds. + +CVE: CVE-2026-82474 +Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575] + +(cherry picked from commit 1a312af6348594df371e6088aeed99685977f575) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/exec_ptrace.c | 31 +++++++++++++++++++++++-------- + 1 file changed, 23 insertions(+), 8 deletions(-) + +diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c +index e780dfd..5b901a7 100644 +--- a/src/exec_ptrace.c ++++ b/src/exec_ptrace.c +@@ -951,9 +951,10 @@ ptrace_write_vec(pid_t pid, struct sudo_ptrace_regs *regs, char **vec, + /* + * Read a link from /proc/PID and store the result in buf. + * Used to read the cwd and exe links in /proc/PID. +- * Returns true on success, else false. ++ * Returns the number of bytes written to buf on success, else -1. ++ * Note: name and buf _may_ overlap. + */ +-static bool ++static ssize_t + proc_read_link(pid_t pid, const char *name, char *buf, size_t bufsize) + { + ssize_t len; +@@ -962,14 +963,14 @@ proc_read_link(pid_t pid, const char *name, char *buf, size_t bufsize) + + len = snprintf(path, sizeof(path), "/proc/%d/%s", (int)pid, name); + if (len > 0 && len < ssizeof(path)) { +- len = readlink(path, buf, bufsize - 1); +- if (len != -1) { ++ len = readlink(path, buf, bufsize); ++ if (len != -1 && (size_t)len != bufsize) { + /* readlink(2) does not add the NUL for us. */ + buf[len] = '\0'; +- debug_return_bool(true); ++ debug_return_ssize_t(len + 1); + } + } +- debug_return_bool(false); ++ debug_return_ssize_t(-1); + } + + /* +@@ -1011,6 +1012,20 @@ get_execve_info(pid_t pid, struct sudo_ptrace_regs *regs, char **pathname_out, + "unable to read execve pathname for process %d", (int)pid); + goto bad; + } ++ ++ /* For fexecve() the path may be in the form /proc/self/fd/N */ ++ if (strncmp(argbuf, "/proc/self/fd/", 14) == 0) { ++ const char *errstr; ++ const char *fdstr = argbuf + 14; ++ (void)sudo_strtonum(fdstr, 0, INT_MAX, &errstr); ++ if (errstr == NULL) { ++ /* Rewrite argbuf with link target (if it is one). */ ++ ssize_t len = proc_read_link(pid, fdstr, argbuf, bufsize); ++ if (len != -1) ++ nread = len; ++ } ++ } ++ + /* Defer setting pathname until after all reallocations are done. */ + off = (size_t)nread; + } +@@ -1626,7 +1641,7 @@ ptrace_verify_post_exec(pid_t pid, struct sudo_ptrace_regs *regs, + } + + /* Get the executable path. */ +- if (!proc_read_link(pid, "exe", pathname, sizeof(pathname))) { ++ if (proc_read_link(pid, "exe", pathname, sizeof(pathname)) == -1) { + /* Missing /proc file system is not a fatal error. */ + sudo_debug_printf(SUDO_DEBUG_ERROR, "%s: unable to read /proc/%d/exe", + __func__, (int)pid); +@@ -1768,7 +1783,7 @@ ptrace_intercept_execve(pid_t pid, struct intercept_closure *closure) + } + + /* Get the current working directory and execve info. */ +- if (!proc_read_link(pid, "cwd", cwd, sizeof(cwd))) ++ if (proc_read_link(pid, "cwd", cwd, sizeof(cwd)) == -1) + (void)strlcpy(cwd, "unknown", sizeof(cwd)); + buf = get_execve_info(pid, ®s, &pathname, &argc, &argv, + &envc, &envp);
meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patch new file +34 -0
@@ -0,0 +1,34 @@ +From e822b729da31baf9154946329a9d6ef569f0d182 Mon Sep 17 00:00:00 2001 +From: "Todd C. Miller" <[email protected]> +Date: Fri, 20 Mar 2026 05:50:47 -0600 +Subject: [PATCH] get_execve_info: pass correct name to proc_read_link() + +CVE: CVE-2026-82474 +Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182] + +(cherry picked from commit e822b729da31baf9154946329a9d6ef569f0d182) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/exec_ptrace.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c +index 5b901a7..5b78702 100644 +--- a/src/exec_ptrace.c ++++ b/src/exec_ptrace.c +@@ -1015,12 +1015,13 @@ get_execve_info(pid_t pid, struct sudo_ptrace_regs *regs, char **pathname_out, + + /* For fexecve() the path may be in the form /proc/self/fd/N */ + if (strncmp(argbuf, "/proc/self/fd/", 14) == 0) { +- const char *errstr; + const char *fdstr = argbuf + 14; ++ const char *name = argbuf + 11; ++ const char *errstr; + (void)sudo_strtonum(fdstr, 0, INT_MAX, &errstr); + if (errstr == NULL) { + /* Rewrite argbuf with link target (if it is one). */ +- ssize_t len = proc_read_link(pid, fdstr, argbuf, bufsize); ++ ssize_t len = proc_read_link(pid, name, argbuf, bufsize); + if (len != -1) + nread = len; + }
meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patch new file +39 -0
@@ -0,0 +1,39 @@ +From d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd Mon Sep 17 00:00:00 2001 +From: "Todd C. Miller" <[email protected]> +Date: Thu, 23 Apr 2026 09:39:35 -0600 +Subject: [PATCH] get_exec_info: error out if we run out of space rewriting + pathname + +Since proc_read_link() is destructive on error we could end up with +missing NUL terminator in the rewritten pathname. +Coverity CID 560390. + +CVE: CVE-2026-82474 +Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd] + +(cherry picked from commit d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/exec_ptrace.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c +index 82a5947..90d6a48 100644 +--- a/src/exec_ptrace.c ++++ b/src/exec_ptrace.c +@@ -1120,8 +1120,13 @@ get_exec_info(pid_t pid, bool is_execveat, struct sudo_ptrace_regs *regs, + if (errstr == NULL) { + /* Rewrite argbuf with link target (if it is one). */ + ssize_t len = proc_read_link(pid, name, argbuf, bufsize); +- if (len != -1) +- nread = len + 1; ++ if (len == -1) { ++ sudo_debug_printf( ++ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO, ++ "unable to rewrite pathname for process %d", (int)pid); ++ goto bad; ++ } ++ nread = len + 1; + } + } +
meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 02b14c043825b52be6cd537b7f11bd5e7e10512e Mon Sep 17 00:00:00 2001 +From: "Todd C. Miller" <[email protected]> +Date: Sat, 25 Apr 2026 12:05:23 -0600 +Subject: [PATCH] Fix handling of relative paths in the execveat(2) intercept + support. + +The code to prepend the directory when fully-qualifying a relative +path used the wrong length the memmove(3) call. + +Reported by and fix from Marius Momeu + +CVE: CVE-2026-82474 +Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512e] + +(cherry picked from commit 02b14c043825b52be6cd537b7f11bd5e7e10512e) +Signed-off-by: Darsh Kelaiya <[email protected]> +--- + src/exec_ptrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/exec_ptrace.c b/src/exec_ptrace.c +index 90d6a48..9521f18 100644 +--- a/src/exec_ptrace.c ++++ b/src/exec_ptrace.c +@@ -1100,7 +1100,7 @@ get_exec_info(pid_t pid, bool is_execveat, struct sudo_ptrace_regs *regs, + goto bad; + } + /* Prepend directory to relative pathname. */ +- memmove(argbuf + len + 1, argbuf, len + 1); ++ memmove(argbuf + len + 1, argbuf, nread); + memcpy(argbuf, dir, len); + argbuf[len] = '/'; + nread += len + 1;
meta/recipes-extended/sudo/files/CVE-2026-82474.patch new file +617 -0
617 lines not on this page · raw message
meta/recipes-extended/sudo/sudo_1.9.17p2.bb +5 -0
@@ -5,6 +5,11 @@ SRC_URI = "https://www.sudo.ws/dist/sudo-${PV}.tar.gz \ file://0001-sudo.conf.in-fix-conflict-with-multilib.patch \ file://0001-m4-Backport-ax_prog_cc_for_build.m4-macros.patch \ file://CVE-2026-35535.patch \ + file://CVE-2026-82474-dependent_p1.patch \ + file://CVE-2026-82474-dependent_p2.patch \ + file://CVE-2026-82474.patch \ + file://CVE-2026-82474-regression_p1.patch \ + file://CVE-2026-82474-regression_p2.patch \ " PAM_SRC_URI = "file://sudo.pam"
Signature · 1 line
2.35.6
Quoted 22 lines · On Fri Oct 16, 2026 at 8:56 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
The recipe enables Linux intercept support. Check execveat commands and log subcommands instead of allowing this syscall unconditionally. Resolve directory file descriptors and
AT_EMPTY_PATHto paths for sudoers policy checks.Apply prerequisites [3] and [4] for
proc_read_link()and fexecve paths. Include follow-ups [5] and [6] to reject failed pathname rewrites and correct relative-path moves. Keep the upstream source changes intact.[1] https://github.com/sudo-project/sudo/commit/71fbe42dcd5a1c8f799540583a2dfb2ae6221edf
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-82474
[3] https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575
[4] https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182
[5] https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd
[6] https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512eSigned-off-by Darsh Kelaiya <[email protected]>
Quoted 13 lines
--- .../files/CVE-2026-82474-dependent_p1.patch | 94 +++ .../files/CVE-2026-82474-dependent_p2.patch | 34 + .../files/CVE-2026-82474-regression_p1.patch | 39 ++ .../files/CVE-2026-82474-regression_p2.patch | 33 + .../sudo/files/CVE-2026-82474.patch | 617 ++++++++++++++++++ meta/recipes-extended/sudo/sudo_1.9.17p2.bb | 5 + 6 files changed, 822 insertions(+) create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474.patch
Hello,
I think this fix is also needed for blacksail and master. Can you send the relevant upgrade/backports so I can merge this on wrynose?
Thanks!
Regards,
Signature · 2 lines
Yoann Congal Smile ECS
Quoted 37 lines · Yoann Congal
Quoted 22 lines · On Fri Oct 16, 2026 at 8:56 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
The recipe enables Linux intercept support. Check execveat commands and log subcommands instead of allowing this syscall unconditionally. Resolve directory file descriptors and
AT_EMPTY_PATHto paths for sudoers policy checks.Apply prerequisites [3] and [4] for
proc_read_link()and fexecve paths. Include follow-ups [5] and [6] to reject failed pathname rewrites and correct relative-path moves. Keep the upstream source changes intact.[1] https://github.com/sudo-project/sudo/commit/71fbe42dcd5a1c8f799540583a2dfb2ae6221edf
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-82474
[3] https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575
[4] https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182
[5] https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd
[6] https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512eSigned-off-by Darsh Kelaiya <[email protected]>Quoted 13 lines
--- .../files/CVE-2026-82474-dependent_p1.patch | 94 +++ .../files/CVE-2026-82474-dependent_p2.patch | 34 + .../files/CVE-2026-82474-regression_p1.patch | 39 ++ .../files/CVE-2026-82474-regression_p2.patch | 33 + .../sudo/files/CVE-2026-82474.patch | 617 ++++++++++++++++++ meta/recipes-extended/sudo/sudo_1.9.17p2.bb | 5 + 6 files changed, 822 insertions(+) create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patch create mode 100644 meta/recipes-extended/sudo/files/CVE-2026-82474.patch
Quoted 4 lines
Hello,
I think this fix is also needed for blacksail and master. Can you send the relevant upgrade/backports so I can merge this on wrynose?
Hello,
This CVE is now fixed on master but the cherry-pick does not apply cleanly for blacksail. Can you send this fix for blacksail as well?
Thanks!
Signature · 2 lines
Yoann Congal Smile ECS
Hi Yoann,
I'm preparing a backport patch for Blacksail also. Will send as soon as possible.
Thanks,
Darsh
Quoted 65 lines · Yoann Congal
Quoted 48 lines · Yoann Congal
Quoted 35 lines · On Fri Oct 16, 2026 at 8:56 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
The recipe enables Linux intercept support. Check execveat commands and log subcommands instead of allowing this syscall unconditionally. Resolve directory file descriptors and
AT_EMPTY_PATHto paths for sudoers policy checks.Apply prerequisites [3] and [4] for
proc_read_link()and fexecve paths. Include follow-ups [5] and [6] to reject failed pathname rewrites and correct relative-path moves. Keep the upstream source changes intact.[1] https://github.com/sudo-project/sudo/commit/71fbe42dcd5a1c8f799540583a2dfb2ae6221edf
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-82474
[3] https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575[4] https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182
[5] https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd
[6] https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512e
Signed-off-by Darsh Kelaiya <[email protected]>---
.../files/CVE-2026-82474-dependent_p1.patch| 94 +++.../files/CVE-2026-82474-dependent_p2.patch| 34 +.../files/CVE-2026-82474-regression_p1.patch| 39 ++.../files/CVE-2026-82474-regression_p2.patch| 33 +.../sudo/files/CVE-2026-82474.patch| 617 ++++++++++++++++++ meta/recipes-extended/sudo/sudo_1.9.17p2.bb | 5 +6 files changed, 822 insertions(+)Quoted 9 lines
create mode 100644
meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474.patchQuoted 4 lines
Hello,
I think this fix is also needed for blacksail and master. Can you send the relevant upgrade/backports so I can merge this on wrynose?
Hello,
This CVE is now fixed on master but the cherry-pick does not apply cleanly for blacksail. Can you send this fix for blacksail as well?
Thanks!
--
Yoann Congal
Smile ECS
Hi Yoann,
I've sent a Blacksail patch:
https://lists.openembedded.org/g/openembedded-core/message/251001
I'll also send the master patch to add regression patches as soon as possible.
Thanks,
Darsh
Quoted 78 lines · On Tue, Nov 17, 2026 at 06:07 PM, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
Hi Yoann,
I'm preparing a backport patch for Blacksail also. Will send as soon as possible.
Thanks,
DarshQuoted 64 lines · Yoann Congal
Quoted 48 lines · Yoann Congal
Quoted 35 lines · On Fri Oct 16, 2026 at 8:56 AM CEST, Darsh Kelaiya -X (dkelaiya - E INFOCHIPS…
From: Darsh Kelaiya <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
The recipe enables Linux intercept support. Check execveat commands and log subcommands instead of allowing this syscall unconditionally. Resolve directory file descriptors and
AT_EMPTY_PATHto paths for sudoers policy checks.Apply prerequisites [3] and [4] for
proc_read_link()and fexecve paths. Include follow-ups [5] and [6] to reject failed pathname rewrites and correct relative-path moves. Keep the upstream source changes intact.[1] https://github.com/sudo-project/sudo/commit/71fbe42dcd5a1c8f799540583a2dfb2ae6221edf
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-82474
[3] https://github.com/sudo-project/sudo/commit/1a312af6348594df371e6088aeed99685977f575[4] https://github.com/sudo-project/sudo/commit/e822b729da31baf9154946329a9d6ef569f0d182
[5] https://github.com/sudo-project/sudo/commit/d1121181a87b2b47b4dfbb2af42399fcc5f1e3cd
[6] https://github.com/sudo-project/sudo/commit/02b14c043825b52be6cd537b7f11bd5e7e10512e
Signed-off-by Darsh Kelaiya <[email protected]>---
.../files/CVE-2026-82474-dependent_p1.patch| 94 +++.../files/CVE-2026-82474-dependent_p2.patch| 34 +.../files/CVE-2026-82474-regression_p1.patch| 39 ++.../files/CVE-2026-82474-regression_p2.patch| 33 +.../sudo/files/CVE-2026-82474.patch| 617 ++++++++++++++++++ meta/recipes-extended/sudo/sudo_1.9.17p2.bb | 5 +6 files changed, 822 insertions(+)Quoted 9 lines
create mode 100644
meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p1.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-dependent_p2.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p1.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474-regression_p2.patchcreate mode 100644meta/recipes-extended/sudo/files/CVE-2026-82474.patchQuoted 4 lines
Hello,
I think this fix is also needed for blacksail and master. Can you send the relevant upgrade/backports so I can merge this on wrynose?
Hello,
This CVE is now fixed on master but the cherry-pick does not apply cleanly for blacksail. Can you send this fix for blacksail as well?
Thanks!
--
Yoann Congal
Smile ECS