Version in base suite: 1.9.16p2-3+deb13u5 Base version: sudo_1.9.16p2-3+deb13u5 Target version: sudo_1.9.16p2-3+deb13u6 Base file: /srv/ftp-master.debian.org/ftp/pool/main/s/sudo/sudo_1.9.16p2-3+deb13u5.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/s/sudo/sudo_1.9.16p2-3+deb13u6.dsc changelog | 8 + patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch | 48 ++++++++++ patches/series | 1 tests/01-getroot | 18 +++ tests/common/asuser | 7 + 5 files changed, 79 insertions(+), 3 deletions(-) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp9gta9csz/sudo_1.9.16p2-3+deb13u5.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp9gta9csz/sudo_1.9.16p2-3+deb13u6.dsc: no acceptable signature found diff -Nru sudo-1.9.16p2/debian/changelog sudo-1.9.16p2/debian/changelog --- sudo-1.9.16p2/debian/changelog 2026-09-29 14:02:29.000000000 +0000 +++ sudo-1.9.16p2/debian/changelog 2026-11-25 06:26:49.000000000 +0000 @@ -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 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 00:00:00.000000000 +0000 +++ sudo-1.9.16p2/debian/patches/0014-os_init_common-always-copy-envp-even-when-it-is-empt.patch 2026-11-25 06:26:33.000000000 +0000 @@ -0,0 +1,48 @@ +From: Michael Kriese +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 +--- + 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 14:02:29.000000000 +0000 +++ sudo-1.9.16p2/debian/patches/series 2026-11-25 06:26:33.000000000 +0000 @@ -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 14:02:29.000000000 +0000 +++ sudo-1.9.16p2/debian/tests/01-getroot 2026-11-25 06:26:33.000000000 +0000 @@ -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 14:02:29.000000000 +0000 +++ sudo-1.9.16p2/debian/tests/common/asuser 2026-11-25 06:26:33.000000000 +0000 @@ -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}"