Bug 567337 (CVE-2010-0426) - CVE-2010-0426 sudo: sudoedit option can possibly allow for arbitrary code execution
Summary: CVE-2010-0426 sudo: sudoedit option can possibly allow for arbitrary code exe...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2010-0426
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 567675 567676 567689 567691
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-02-22 17:08 UTC by Vincent Danen
Modified: 2019-09-29 12:34 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-03-29 08:56:08 UTC


Attachments (Terms of Use)
patch from upstream to fix the flaw in sudo 1.7.x (393 bytes, patch)
2010-02-22 22:44 UTC, Vincent Danen
no flags Details | Diff
patch backported to sudo 1.6.x (352 bytes, patch)
2010-02-22 22:45 UTC, 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 23:42 UTC, Vincent Danen
no flags Details | Diff
patch backported to sudo 1.6.x (simplified) (371 bytes, patch)
2010-02-22 23:43 UTC, Vincent Danen
no flags Details | Diff


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2010:0122 normal SHIPPED_LIVE Important: sudo security update 2010-02-26 11:06:06 UTC

Description Vincent Danen 2010-02-22 17:08:38 UTC
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 17:11:56 UTC
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 22:44:19 UTC
Created attachment 395599 [details]
patch from upstream to fix the flaw in sudo 1.7.x

Comment 3 Vincent Danen 2010-02-22 22:45:16 UTC
Created attachment 395600 [details]
patch backported to sudo 1.6.x

Comment 4 Vincent Danen 2010-02-22 23:42:49 UTC
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 23:43:59 UTC
Created attachment 395606 [details]
patch backported to sudo 1.6.x (simplified)

Comment 6 Jan Lieskovsky 2010-02-23 10:56:42 UTC
This is CVE-2010-0426.

Comment 12 errata-xmlrpc 2010-02-26 11:06:11 UTC
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 16:22:27 UTC
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 12:56:24 UTC
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 12:56:27 UTC
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 13:00:20 UTC
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 13:03:26 UTC
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-06 03:53:26 UTC
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-09 03:13:04 UTC
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 06:45:54 UTC
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.