Article View: linux.debian.bugs.dist
Article #6178Bug#1155346: trixie-pu: package sudo/1.9.16p2-3+deb13u6
From: Marc Haber
Date: Wed, 25 Nov 2026 20:00
Date: Wed, 25 Nov 2026 20:00
176 lines
8745 bytes
8745 bytes
This is a multi-part MIME message sent by reportbug.
--===============4488353172207869289==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: sudo@packages.debian.org
Control: affects -1 + src:sudo
User: release.debian.org@packages.debian.org
Usertags: pu
This upload fixe a segfault regression introduced by the 13.8 point
release. This probably warrants a fasttrack-update via trixie-updates
and a corresponding advisory. If you disagree, please consider this
upload for 13.9. Same reasons.
[ Reason ]
sudo 1.9.16p2-3+deb13u5 has a regression bug and segfaults if the
environment is empty. reproducer: env -i sudo id.
[ Impact ]
sudo segfaults if called with empty environment. emptying the
environment is a common idiom in security-aware scripts.
A segfault in an suid binary is almost always a bad news. However,
upstream agrees with the Debian security team that this doesnt warrant a
security release.
[ Tests ]
This update includes a new autopkgtest part that checks sudo with empty
environment. It is verified to fail in sudo 1.9.16p2-3+deb13u5 and to
pass with this patch.
[ Risks ]
The patch could be buggy as welll.
[ Checklist ]
[x] *all* changes are documented in the d/changelog
[x] I reviewed all changes and I approve them
[x] attach debdiff against the package in (old)stable
[x] the issue is verified as fixed in unstable
[ Changes ]
Add patch to fix the issue
Add autopkgtest that checks for the issue.
--===============4488353172207869289==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="sudo_1.9.16p2-3+deb13u5_1.9.16p2-3+deb13u6.debdiff"
diff -Nru sudo-1.9.16p2/debian/changelog sudo-1.9.16p2/debian/changelog
--- sudo-1.9.16p2/debian/changelog 2026-09-29 16:02:29.000000000 +0200
+++ sudo-1.9.16p2/debian/changelog 2026-11-25 07:26:49.000000000 +0100
@@ -1,3 +1,11 @@
+sudo (1.9.16p2-3+deb13u6) trixie; urgency=medium
+
+ * add autopkgtest to test sudo with empty environment
+ * add upstream patch: always copy envp, even when it is empty.
+ Thanks to Michael Kriese (Closes: #1154725)
+
+ -- Marc Haber <mh+debian-packages@zugschlus.de> Wed, 25 Nov 2026 07:26:49 +0100
+
sudo (1.9.16p2-3+deb13u5) trixie; urgency=medium
* bump version number to allow git-debpush to work again
diff -Nru sudo-1.9.16p2/debian/patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch sudo-1.9.16p2/debian/patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch
--- sudo-1.9.16p2/debian/patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch 1970-01-01 01:00:00.000000000 +0100
+++ sudo-1.9.16p2/debian/patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch 2026-11-25 07:26:33.000000000 +0100
@@ -0,0 +1,48 @@
+From: Michael Kriese <michael.kriese@gmx.de>
+Date: Mon, 23 Nov 2026 13:16:34 +0100
+Subject: os_init_common: always copy envp, even when it is empty
+
+Since 194042b, submit_envp is only allocated when the environment
+is not empty. With an empty environment (e.g. "env -i sudo true")
+it stays NULL and the plugins get a NULL envp, which makes sudoers.so
+crash with a NULL pointer dereference. Allocate the copy
+unconditionally so plugins always get a NULL-terminated array.
+
+Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@gmx.de>
+---
+ src/sudo.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/src/sudo.c b/src/sudo.c
+index de7e809..93a3c50 100644
+--- a/src/sudo.c
++++ b/src/sudo.c
+@@ -375,19 +375,19 @@ os_init_common(int argc, char *argv[], char *envp[])
+ * Make a shallow copy of envp[] and store in submit_envp[].
+ * This allows us to remove variables from sudo's environment
+ * while still providing the original envp to the plugins.
++ * The copy is made even for an empty environment since the
++ * plugins expect a non-NULL envp.
+ */
+ for (envc = 0; envp[envc] != NULL; envc++)
+ continue;
+- if (envc != 0) {
+- submit_envp = reallocarray(NULL, sizeof(char *), envc + 1);
+- if (submit_envp == NULL || !gc_add(GC_PTR, submit_envp)) {
+- sudo_fatalx_nodebug(U_("%s: %s"), __func__,
+- U_("unable to allocate memory"));
+- }
+- for (envc = 0; envp[envc] != NULL; envc++)
+- submit_envp[envc] = envp[envc];
+- submit_envp[envc] = NULL;
++ submit_envp = reallocarray(NULL, sizeof(char *), envc + 1);
++ if (submit_envp == NULL || !gc_add(GC_PTR, submit_envp)) {
++ sudo_fatalx_nodebug(U_("%s: %s"), __func__,
++ U_("unable to allocate memory"));
+ }
++ for (envc = 0; envp[envc] != NULL; envc++)
++ submit_envp[envc] = envp[envc];
++ submit_envp[envc] = NULL;
+
+ return 0;
+ }
diff -Nru sudo-1.9.16p2/debian/patches/series sudo-1.9.16p2/debian/patches/series
--- sudo-1.9.16p2/debian/patches/series 2026-09-29 16:02:29.000000000 +0200
+++ sudo-1.9.16p2/debian/patches/series 2026-11-25 07:26:33.000000000 +0100
@@ -11,3 +11,4 @@
0011-sudo-ignore-user-specified-TZ-environment-variable.patch
0012-Remove-TZ-from-sudo-s-working-environment-without-mo.patch
0013-Copy-envp-submit_envp-instead-of-replacing-the-envir.patch
+0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch
diff -Nru sudo-1.9.16p2/debian/tests/01-getroot sudo-1.9.16p2/debian/tests/01-getroot
--- sudo-1.9.16p2/debian/tests/01-getroot 2026-09-29 16:02:29.000000000 +0200
+++ sudo-1.9.16p2/debian/tests/01-getroot 2026-11-25 07:26:33.000000000 +0100
@@ -96,5 +96,21 @@
fi
done
-printf "test series sucessful, exit 0\n"
+printf "========= test %s\.4: account group member, empty sudo environment\n" "${TESTNR}"
+rm -f "${HOMEDIRA}/std*"
+RET=0
+printf "trying %s with empty sudo environment\n" "${ACCTA}"
+su - "${ACCTA}" -c "ASUSER_EMPTY_ENV=1 ${COMMONDIR}/asuser ${PASSWD}" || RET=$?
+printf "%s with empty sudo environment, return value %s\n" "${ACCTA}" "${RET}"
+if [ "$(cat ${HOMEDIRA}/stdout)" != "0" ]; then
+ echo >&2 "id -u did not give 0"
+ printf >&2 "stdout:\n"
+ cat >&2 "${HOMEDIRA}/stdout"
+ printf >&2 "stderr:\n"
+ cat >&2 "${HOMEDIRA}/stderr"
+ printf >&2 "exit code %s\n" "${RET}"
+ exit 1
+fi
+
+printf "test series successful, exit 0\n"
exit 0
diff -Nru sudo-1.9.16p2/debian/tests/common/asuser sudo-1.9.16p2/debian/tests/common/asuser
--- sudo-1.9.16p2/debian/tests/common/asuser 2026-09-29 16:02:29.000000000 +0200
+++ sudo-1.9.16p2/debian/tests/common/asuser 2026-11-25 07:26:33.000000000 +0100
@@ -2,6 +2,9 @@
set -e
-echo "${1:-}" | sudo -u "${2:-root}" --stdin id -u > "${3:-stdout}" 2> "${4:-stderr}"
-
+ENVI=""
+if [[ "${ASUSER_EMPTY_ENV:-}" = 1 ]]; then
+ ENVI="env -i"
+fi
+echo "${1:-}" | ${ENVI} /usr/bin/sudo -u "${2:-root}" --stdin id -u > "${3:-stdout}" 2> "${4:-stderr}"
--===============4488353172207869289==--
Technical Details
Message-ID:
<O3rjP-e7Z9-3@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod From: Marc Haber <mh+debian-packages@zugschlus.de> Newsgroups: linux.debian.bugs.dist,linux.debian.devel.release Subject: Bug#1155346: trixie-pu: package sudo/1.9.16p2-3+deb13u6 Date: Wed, 25 Nov 2026 21:00:01 +0100 Message-ID: <O3rjP-e7Z9-3@gated-at.bofh.it> X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Wed Nov 25 19:57:09 2026 Old-Return-Path: <debbugs@buxtehude.debian.org> X-Spam-Flag: NO X-Spam-Score: -1.651 Reply-To: Marc Haber <mh+debian-packages@zugschlus.de>, 1155346@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: sudo@packages.debian.org, debian-release@lists.debian.org X-Debian-Pr-Message: report 1155346 X-Debian-Pr-Package: release.debian.org X-Debian-Pr-Keywords: trixie Resent-To: submit@bugs.debian.org Content-Type: multipart/mixed; boundary="===============4488353172207869289==" MIME-Version: 1.0 X-Mailer: reportbug 13.2.0+nmu1 X-Crossassassin-Score: 2 X-Debian-Message: from BTS X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2005025 List-ID: <debian-bugs-dist.lists.debian.org> List-URL: <https://lists.debian.org/debian-bugs-dist/> Approved: robomod@news.nic.it Lines: 176 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Wed, 25 Nov 2026 08:20:48 +0100 X-Original-Message-ID: <179559124865.2069029.17713009562882274565.reportbug@swivel>