Bug 493158 (CVE-2009-1185) - VUL-0: CVE-2009-1185 CVE-2009-1186: udev local root vulnerability
Summary: VUL-0: CVE-2009-1185 CVE-2009-1186: udev local root vulnerability
Status: RESOLVED FIXED
: CVE-2017-7874 (view as bug list)
Alias: CVE-2009-1185
Product: SUSE Security Incidents
Classification: Novell Products
Component: General (show other bugs)
Version: unspecified
Hardware: Other Other
: P2 - High : Major
Target Milestone: ---
Deadline: 2009-04-15
Assignee: Michal Hocko
QA Contact: E-mail List
URL:
Whiteboard: maint:released:10.3:23854 maint:relea...
Keywords:
Depends on:
Blocks: 550249
  Show dependency treegraph
 
Reported: 2009-04-08 09:35 UTC by Sebastian Krahmer
Modified: 2017-04-19 13:24 UTC (History)
7 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
PoC (5.00 KB, text/x-csrc)
2009-04-08 13:21 UTC, Sebastian Krahmer
Details
check sender of netlink message (1.07 KB, patch)
2009-04-09 05:01 UTC, Kay Sievers
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Krahmer 2009-04-08 09:35:47 UTC
udevd doesnt check nl_pid to equal 0 for KOBJECT_UEVENT messages
which allows users to fake such messages, fooling
udevd to create mode 0666 block devices or to run
network scripts with weird interface names.

Additionally there is a overflow in the
path encoding:

size_t util_path_encode(char *s, size_t len)
{
        char t[(len * 3)+1];
        size_t i, j;

        t[0] = '\0';
        for (i = 0, j = 0; s[i] != '\0'; i++) {
                if (s[i] == '/') {
                        memcpy(&t[j], "\\x2f", 4);//AUD: overflow
                        j += 4;
                } else if (s[i] == '\\') {
                        memcpy(&t[j], "\\x5c", 4);
                        j += 4;
                } else {
                        t[j] = s[i];
                        j++;
                }
        }
        t[j] = '\0';
        strncpy(s, t, len);
        return j;
}

it should reserve 4 times not 3 times len :)
Comment 2 Marcus Meissner 2009-04-08 12:29:01 UTC
cc greg, the other udev author ;)
Comment 3 Kay Sievers 2009-04-08 13:00:06 UTC
(In reply to comment #0)
> udevd doesnt check nl_pid to equal 0 for KOBJECT_UEVENT messages
> which allows users to fake such messages

How can a normal user send netlink messages on this socket? It should only accept messages from root.
Comment 4 Sebastian Krahmer 2009-04-08 13:21:40 UTC
Created attachment 284763 [details]
PoC

...
Comment 5 Sebastian Krahmer 2009-04-08 13:22:43 UTC
anyone can send netlink messages. for me it doesnt make
much sense to send KOBJECT_UEVENT messages from userland either,
so call it a kernel weirdness if you like. But any
message which has not a pid of 0 in src address struct
is from userland. proof of concept exploit attached.
Comment 6 Kay Sievers 2009-04-08 13:46:06 UTC
Non-root users can not even listen to the events.
Oh, what a very useful kernel feature, that they can send events. :)
Thanks!
Comment 7 Kay Sievers 2009-04-08 14:55:23 UTC
(In reply to comment #0)
> udevd doesnt check nl_pid

There is no such field to check, I need to enable credential passing and check these, right?

We do the credential check for the unix socket already, and doing the same for netlink should work, right?

The changes are here:
  http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h=e2b362d9f23d4c63018709ab5f81a02f72b91e75

Thanks,
Kay
Comment 8 Kay Sievers 2009-04-09 05:01:59 UTC
Created attachment 284932 [details]
check sender of netlink message

Patch against udev version 128
Comment 9 Marcus Meissner 2009-04-09 08:50:30 UTC
Assigned CVE-2009-1185 for 'udev doesn't check for origin of NETLINK message'
         CVE-2009-1186 for 'udev buffer overflow in util_path_encode()'

Regards, Jan.
--
Jan iankko Lieskovsky / Red Hat Security Response Team
Comment 10 Swamp Workflow Management 2009-04-09 11:27:51 UTC
The SWAMPID for this issue is 23830.
Please submit the patch and patchinfo file using this ID.
(https://swamp.suse.de/webswamp/wf/23830)
Comment 11 Marcus Meissner 2009-04-09 11:33:58 UTC
Kay, if SLES 10 SP2 is affected by this problem also roll in the planned
updates for sle10sp2. (only if they do not take too long to integrate those bugfix patches)

bugs 446534 467217 447995 478132


when everything is submitted for all affected distros, please reassign back to
security-team@suse.de and we do the patchinfos and the rest
Comment 12 Kay Sievers 2009-04-09 14:53:13 UTC
> roll in the planned updates for sle10sp2
> if they do not take too long to integrate those
> bugfixes:
>    446534 467217 447995 478132

Hannes, care to prepare the tape rule updates?
Comment 13 Hannes Reinecke 2009-04-09 16:03:42 UTC
multipath-tools is affected from this problem, too.
Comment 14 Hannes Reinecke 2009-04-09 16:19:57 UTC
New udev rpm has been submitted for SLES10.
Comment 15 Hannes Reinecke 2009-04-09 16:25:22 UTC
> multipath-tools is affected from this problem, too.

False alarm. We're using the netlink socket only as a fallback when the unix socket provided by udev is not available. Which is on our distribution.
So only upstream multipath-tools is affected.
Comment 16 Hannes Reinecke 2009-04-09 16:57:09 UTC
New udev rpms have been submitted for 11.0 and 11.1
Comment 17 Hannes Reinecke 2009-04-09 17:04:42 UTC
New udev rpm has been submitted for 10.3.

Done on this end, reassigning.
Comment 18 Kay Sievers 2009-04-09 17:16:40 UTC
SLE10-sp2, 10.3, 11.0, 11.1, SLE11, Factory(version update) are all submitted
Comment 19 Kay Sievers 2009-04-15 22:22:35 UTC
(In reply to comment #15)
> > multipath-tools is affected from this problem, too.
> 
> False alarm. We're using the netlink socket only as a fallback when the unix
> socket provided by udev is not available. Which is on our distribution.
> So only upstream multipath-tools is affected.

It that your code? Do you check credentials on the unix socket? The upstream code, unrelated to the netlink issue, seems to accept any sender on the unix socket that listens to udev.
Comment 20 Swamp Workflow Management 2009-04-16 11:22:19 UTC
Update released for: libudev-devel, libudev0, libvolume_id, libvolume_id-devel, libvolume_id1, udev, udev-debuginfo, udev-debugsource
Products:
openSUSE 10.3 (i386, ppc, x86_64)
openSUSE 11.0 (debug, i386, ppc, x86_64)
openSUSE 11.1 (debug, i586, ppc, x86_64)
Comment 21 Marcus Meissner 2009-04-16 11:28:25 UTC
hmm.

on secondary review I see you fioxed the netlink issue, but not the overflow.

any reason for the overflow niot being fixed?

(I have released the netlink fix as it was urgent already)
Comment 22 Hannes Reinecke 2009-04-16 12:09:37 UTC
No reason. I have just been informed about the netlink issue as a matter of urgency, and prepared the patch etc whilst being on the road (at the collaboration summit to be precise). And the overflow was deemed of a rather low urgency, as you would have to prepare a _kernel_ device path consisting of just unicode characters.

Anyone capable of doing so deserves the merit of crashing udev :-)
And we would be crashing the udev worker programs only, so at worst udev wouldn't generate a device node for this; I can't really see how it would affect udevd itself. Hence the rather low urgency here.
Comment 23 Marcus Meissner 2009-04-16 14:09:03 UTC
adding to the advisory:

5) Pending Vulnerabilities, Solutions, and Work-Arounds:

   The fix for the buffer overflow in util_path_encode() (CVE-2009-1186) 
   has been postponed to a later udev release due to the urgency of the
   netlink problem. It is also rated lower, since local users cannot directly
   trigger the problematic code path.
Comment 24 Marcus Meissner 2009-04-16 16:32:19 UTC
update released, advisory released, new bug for the second issue is bug 495586
Comment 25 Marcus Meissner 2009-04-21 07:46:56 UTC
hmpf,

udev on sles10 does not auto-restart, so customers need to restart udevd
themselves.

the other distros do restart on update.
Comment 26 Marcus Meissner 2009-04-21 14:36:41 UTC
Patch25:        udev-netlink-credentials


is NOT APPLIED to the SLE10-SP2 update!
Comment 27 Swamp Workflow Management 2009-04-21 14:40:34 UTC
The SWAMPID for this issue is 23830.
Please submit the patch and patchinfo file using this ID.
(https://swamp.suse.de/webswamp/wf/23830)
Comment 28 Marcus Meissner 2009-04-21 14:59:48 UTC
Only sles10-sp2 missed it, the others did not.

I resubmitted udev to sle10sp2, did a new patchinfo and submitted it.

I also marked udev as RebootNeeded: yes, since it does not autorestart on sle10.
Comment 33 Hannes Reinecke 2009-07-07 13:39:50 UTC
Updated multipath-tools has been submitted to maintenance for SLES10 SP2.
Comment 34 Michal Hocko 2009-07-16 15:10:33 UTC
Any update for this bug, Regis? It somehow got stalled.
Comment 35 Hannes Reinecke 2009-07-31 12:41:35 UTC
Resubmitted new multipath-tools rpm for SLES10-SP2.
Comment 37 Swamp Workflow Management 2009-08-28 22:08:38 UTC
Update released for: multipath-tools
Products:
SLE-DEBUGINFO 10-SP2 (i386, ia64, ppc, s390x, x86_64)
SLE-DESKTOP 10-SP2 (i386, x86_64)
SLE-SERVER 10-SP2 (i386, ia64, ppc, s390x, x86_64)
Comment 38 Thomas Biege 2009-10-14 02:23:20 UTC
CVE-2009-1185: CVSS v2 Base Score: 7.2 (AV:L/AC:L/Au:N/C:C/I:C/A:C)
Comment 39 Marcus Meissner 2017-04-19 13:24:34 UTC
*** Bug 1034330 has been marked as a duplicate of this bug. ***