Bug 567337 - (CVE-2010-0426) CVE-2010-0426 sudo: sudoedit option can possibly allow for arbitrary code execution
CVE-2010-0426 sudo: sudoedit option can possibly allow for arbitrary code exe...
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
high Severity high
: ---
: ---
Assigned To: Red Hat Product Security
impact=important,source=debian,report...
: Security
Depends On: 567675 567676 567689 567691
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-22 12:08 EST by Vincent Danen
Modified: 2010-03-29 04:56 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-03-29 04:56:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
patch from upstream to fix the flaw in sudo 1.7.x (393 bytes, patch)
2010-02-22 17:44 EST, Vincent Danen
no flags Details | Diff
patch backported to sudo 1.6.x (352 bytes, patch)
2010-02-22 17:45 EST, Vincent Danen
no flags Details | Diff
patch from upstream to fix the flaw in sudo 1.7.x (simplified) (399 bytes, patch)
2010-02-22 18:42 EST, Vincent Danen
no flags Details | Diff
patch backported to sudo 1.6.x (simplified) (371 bytes, patch)
2010-02-22 18:43 EST, Vincent Danen
no flags Details | Diff

  None (edit)
Description Vincent Danen 2010-02-22 12:08:38 EST
It was reported [1] that sudoedit can allow for arbitrary code execution due to the sudoers configuration file not properly handling the special command name "sudoedit".  In the sudoers file, the sudoedit special command is supposed to allow a user to use sudoedit to edit a specified file as another user (i.e. as an alias to sudo -e), however it can be abused to allow for the execution of arbitrary code.

In sudoers, defining something like: "user ALL=(ALL) sudoedit /etc/sysconfig/autofs" should grant the user the rights to edit /etc/sysconfig/autofs using the /usr/bin/sudoedit command or "sudo -e /etc/sysconfig/autofs", however:

% sudoedit /etc/sysconfig/autofs
[opens file in vim]
% sudoedit /etc/sysconfig/autoff  
[sudo] password for user: 
Sorry, user user is not allowed to execute 'sudoedit /etc/sysconfig/autoff' as root on host.com.
% sudo -e /etc/sysconfig/autofs
[opens file in vim]
% sudo -e /etc/sysconfig/autoff 
[sudo] password for user: 
Sorry, user user is not allowed to execute 'sudoedit /etc/sysconfig/autoff' as root on host.com.
% echo whoami >sudoedit
% chmod 755 sudoedit
% ./sudoedit
user
% sudo ./sudoedit
[sudo] password for user: 
Sorry, user user is not allowed to execute './sudoedit' as root on host.com.
% sudo ./sudoedit /etc/sysconfig/autofs
root
% rpm -q sudo
sudo-1.7.1-7.fc12.x86_64

If the defined file to edit is passed as an argument to "./sudoedit", then sudo will execute the script with the associated privileges.

Verified this happens also on Red Hat Enterprise Linux 5 (sudo-1.6.9p17-5.el5).  I have not yet checked earlier versions, but the Debian report indicates this was not a problem with sudo-1.6.8p12-12.el5.

It is possible this is due to sudoedit being both a special command in sudoers and also an actual system command (/usr/bin/sudoedit).  If the sudoers file contains the full path of sudoedit (treating it as a command rather than a special configuration command), it is not possible to perform the above.  Note that the sudoedit executable is only present in RHEL5 and Fedora, and not in RHEL4 or earlier.  According to the sudoers manpage on RHEL4, sudoedit is not a valid special command either, so this would be an issue only on RHEL5 and Fedora, and would not affect earlier versions.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=570737
Comment 1 Vincent Danen 2010-02-22 12:11:56 EST
The relevant section in the sudoers(5) manpage states that "sudoedit" should be a magic command so should not require the full path:

        Cmnd ::= '!'* commandname |
                 '!'* directory |
                 '!'* "sudoedit" |
                 '!'* Cmnd_Alias

...
The special command "sudoedit" is used to permit a user to run sudo with the -e option (or as sudoedit).  It may take command line arguments just as a normal command does.
Comment 2 Vincent Danen 2010-02-22 17:44:19 EST
Created attachment 395599 [details]
patch from upstream to fix the flaw in sudo 1.7.x
Comment 3 Vincent Danen 2010-02-22 17:45:16 EST
Created attachment 395600 [details]
patch backported to sudo 1.6.x
Comment 4 Vincent Danen 2010-02-22 18:42:49 EST
Created attachment 395605 [details]
patch from upstream to fix the flaw in sudo 1.7.x (simplified)

Todd sent this instead as a simplified patch.
Comment 5 Vincent Danen 2010-02-22 18:43:59 EST
Created attachment 395606 [details]
patch backported to sudo 1.6.x (simplified)
Comment 6 Jan Lieskovsky 2010-02-23 05:56:42 EST
This is CVE-2010-0426.
Comment 12 errata-xmlrpc 2010-02-26 06:06:11 EST
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2010:0122 https://rhn.redhat.com/errata/RHSA-2010-0122.html
Comment 13 Jan Lieskovsky 2010-02-26 11:22:27 EST
This issue did NOT affect the versions of the sudo package, 
as shipped with Red Hat Enterprise Linux 3 and 4.

This issue affects the current versions of the sudo package,
as shipped with Fedora release of 11 and 12.

Please fix.
Comment 14 Fedora Update System 2010-03-01 07:56:24 EST
sudo-1.7.2p5-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/sudo-1.7.2p5-1.fc11
Comment 15 Fedora Update System 2010-03-01 07:56:27 EST
sudo-1.7.2p5-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/sudo-1.7.2p5-1.fc12
Comment 16 Fedora Update System 2010-03-01 08:00:20 EST
sudo-1.7.2p5-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/sudo-1.7.2p5-1.fc12
Comment 17 Fedora Update System 2010-03-01 08:03:26 EST
sudo-1.7.2p5-1.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/sudo-1.7.2p5-1.fc13
Comment 18 Fedora Update System 2010-03-05 22:53:26 EST
sudo-1.7.2p5-1.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 19 Fedora Update System 2010-03-08 22:13:04 EST
sudo-1.7.2p5-1.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 20 Fedora Update System 2010-03-10 01:45:54 EST
sudo-1.7.2p5-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.