Anders Kaseorg and Evan Broder reported a flaw in the way sudo handled duplicated environment variables. When sudo set certain environment variables (such as PATH set to secure_path value, or special sudo environment variables SUDO_*), the value overwrote first value from user's environment (if it had been preserved and had not removed previously due to env_reset / env_keep / env_delete settings), but left following environment variables with the same name unchanged.
This problem can be used to override secure_path setting from /etc/sudoers file for shell scripts executed using sudo, as bash uses last PATH environment variable value. In configurations where secure_path is used to enforce sane PATH setting for shell scripts, this can allow users with the privileges to run some script using sudo to run arbitrary command with the privileges of the target user.
Upstream fixes to handle duplicated environment variables:
http://www.sudo.ws/repos/sudo/rev/3057fde43cf0http://www.sudo.ws/repos/sudo/rev/a09c6812eaec
This issue affects sudo packages shipped in Red Hat Enterprise Linux 5, however not the default configuration. In default configuration, no secure_path is set. env_reset is used by default, and PATH is not preserved during the environment reset (unlike the upstream sudo default).
The sudo packages in Red Hat Enterprise Linux 3 and 4 do not allow setting secure_path in the /etc/sudoers, there is no compile-time default for the secure_path either. Whether the user PATH setting is preserved depends on env_reset / env_delete configuration.
Current Fedora configuration specifies secure_path, but also removes PATH from the environment by default.