can cause root user to remove arbitrary files

Bug #973687 reported by Kees Cook
262
This bug affects 1 person
Affects Status Importance Assigned to Milestone
whoopsie-daisy (Ubuntu)
Fix Released
Critical
Evan

Bug Description

/etc/cron.daily/whoopsie does not use NULL terminated filenames when examining the world-writable directory /var/crash. This allows users to inject whitespace into filenames causing "rm" to delete relative files in the current directory (which happens to be "/" due to it being run from cron) or the /var/crash directory. While there really shouldn't be any _files_ in /, it could be a DoS, and at the least allows removal of other people's crash reports.

For example:

$ touch "/var/crash/chicken monkey duck.uploaded"
$ find /var/crash -name '*.uploaded' -type f -size 0 | sed 's,\(.*\).uploaded$,\1.upload \1.uploaded,'
/var/crash/chicken monkey duck.upload /var/crash/chicken monkey duck.uploaded
/var/crash/monkey.upload /var/crash/monkey.uploaded

The above would lead to removing /var/crash/chicken and /monkey

Revision history for this message
Kees Cook (kees) wrote : Re: can cause root user to remove arbitrary files from / and /var/crash

(This was reported to me by Tavis Ormandy.)

summary: - can cause root user to remove arbitrary files from /
+ can cause root user to remove arbitrary files from / and /var/crash
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

This is CVE-2012-0945

Changed in whoopsie-daisy (Ubuntu):
status: New → Confirmed
importance: Undecided → Critical
assignee: nobody → Evan Dandrea (ev)
Revision history for this message
Steve Beattie (sbeattie) wrote :

Uh, it's more serious than just files in / and /var/crash, you can delete any file on the filesystem with this. e.g.

$ mkdir '/var/crash/chicken monkey/'
$ touch /var/crash/chicken\ monkey/fling\ duck.uploaded
$ find /var/crash -name '*.uploaded' -type f -size 0 | sed 's,\(.*\).uploaded$,\1.upload \1.uploaded,'
/var/crash/chicken monkey/fling duck.upload /var/crash/chicken monkey/fling duck.uploaded

i.e. it will attempt to delete monkey/fling; obviously anything else can be substituted for monkey/fling, like say etc/shadow.

Kees Cook (kees)
summary: - can cause root user to remove arbitrary files from / and /var/crash
+ can cause root user to remove arbitrary files
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Any progress on this, Evan?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

The command should handle files with embedded newlines, and shouldn't enter into subdirectories as that can be raced.

Normally, something like this could be used:

find /var/crash -mindepth 1 -maxdepth 1 -name '*.uploaded' -type f -size 0 -print0 | xargs -0 rm -rf

Attempting to use the additional sed in there is difficult, and I can't think of a way to do it properly right now.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

How about just erasing whatever is old?

find /var/crash -mindepth 1 -maxdepth 1 -name '*.upload*' -type f -mtime +7 -print0 | xargs -0 rm -rf

In theory .uploaded files should always be newer than .upload files...so the job could in theory erase an .upload file without erasing the .uploaded file, which will then get erased the next day.

Evan (ev)
Changed in whoopsie-daisy (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package whoopsie-daisy - 0.1.26

---------------
whoopsie-daisy (0.1.26) precise; urgency=low

  * Take ownership of the NetworkManager state variant on setup and
    unref it, plugging a memory leak.
  * Log the reason the server rejected the submitted crash report.
  * Send the Whoopsie version with each crash submission.
  * Delete both .upload and .uploaded files after 14 days. Thanks
    Marc Deslauriers (LP: #973687).
 -- Evan Dandrea <email address hidden> Tue, 10 Apr 2012 14:28:58 +0100

Changed in whoopsie-daisy (Ubuntu):
status: Fix Committed → Fix Released
visibility: private → public
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.