Repository navigation
os_init_common: always copy envp, even when it is empty - #604
Merged
Merged
Conversation
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>
millert
approved these changes
Nov 23, 2026
millert
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, thanks for finding the source of the problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 194042b ("Copy envp -> submit_envp instead of replacing the environ pointer."),
os_init_common()only allocatessubmit_envpwhen the environment is not empty. With an empty environment it staysNULL, and the plugins get aNULLenvp: sudoers.so then crashes with a NULL pointer dereference.Reproducer (sudo 1.9.18 from
main, Debian 13):mainwith and without this change in adebian:trixiecontainer. Without it,env -i sudo truesegfaults as root and as an unprivileged user; with it, both exit 0.make checkpasses.proc_open()gets an empty environment, upstream sudo bug in trixie? AllskyTeam/allsky#5668.Drafted by Claude Code (Claude Opus 5.5, low effort) on behalf of @viceice.