Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Dirty COW, CVE-2016-5195, was a nine-year-old race condition in the Linux kernel that let any local user write to read-only files and escalate to root on almost every distribution.

What Is Dirty COW?
Dirty COW is CVE-2016-5195, a privilege escalation vulnerability in the Linux kernel disclosed on 19 October 2016. The name is a contraction of “dirty copy-on-write”, and it describes a race condition in the kernel’s memory subsystem that allowed an unprivileged local user to write to files they only had permission to read. Overwriting /etc/passwd or a setuid binary turns that into root access within seconds.
Two things made it notable. It worked on essentially every Linux system in use at the time, including Android, embedded devices, and container hosts. And it had been present since kernel 2.6.22, released in 2007, meaning it sat in the most heavily reviewed open source codebase in the world for nine years.
When a process maps a file privately with MAP_PRIVATE, the kernel does not duplicate the pages immediately. It maps the original, read-only, and waits. If the process writes, a page fault occurs, the kernel copies the page, and the write lands on the private copy. The original file is untouched. This is copy-on-write, and it is what makes fork() cheap.
The flaw was in the handling of that fault. By racing two threads — one repeatedly writing to the mapping through /proc/self/mem, the other repeatedly calling madvise() with MADV_DONTNEED to discard the private copy — an attacker could occasionally get the kernel to lose track of which page the write should target. The write then reached the original, read-only page cache entry rather than the private copy, modifying the file’s contents in memory and, for many file systems, on disk.
The exploit was short, portable, and extremely reliable. Proof of concept code appeared within hours of disclosure.
Phil Oester discovered it by capturing traffic to a compromised server and finding an exploit binary in it, which means it was being used in the wild before it was reported. Linus Torvalds noted that he had attempted to fix the same race in 2005 but the fix had been reverted because of problems on s390 hardware.
The patch landed quickly in the mainline kernel and distributions shipped updates within days. Android was the harder problem: the ZNIU malware family used Dirty COW to root devices in 2017, and the fragmented update landscape meant many handsets stayed vulnerable for a long time afterwards. Embedded and industrial Linux devices, where kernels are often frozen at the version the vendor certified, were worse again.
Dirty COW is patched everywhere that receives patches. It remains relevant for three reasons.
Detecting exploitation after the fact is difficult, because the technique leaves little on disk beyond the modified file. Useful signals include unexpected changes to /etc/passwd, /etc/shadow, or setuid binaries, which file integrity monitoring should catch; processes making heavy use of madvise() combined with writes to /proc/self/mem, which audit rules can record; and new root-owned processes with an unexpected parent.
Preventively, the controls that matter are the ordinary ones: keep kernels current and reboot after updating, or use live patching where downtime is costly; minimise the number of users with local shell access; and apply seccomp and mandatory access control so that a process cannot reach the syscalls a given exploit needs.
Where you have Linux estates that cannot be patched quickly, our infrastructure security testing services identify which hosts are genuinely reachable by an attacker who already has a local account.
No. It is a local privilege escalation and requires the attacker to be able to execute code on the system already, whether through a shell account, a compromised web application, or a container. In real intrusions it was used as the second step, after a remote vulnerability or stolen credentials provided initial access as an unprivileged user.
Every kernel from 2.6.22, released in 2007, up to the versions patched in October 2016, which covered essentially all distributions and Android releases in use at the time. Fixed versions appeared quickly in the mainline kernel and in distribution updates. Anything still running an unpatched kernel from that period has many other problems alongside this one.
It was a race condition in a rarely exercised path of the memory management code, triggered only by an unusual combination of operations with precise timing. Race conditions do not show up in ordinary testing or code review, because the faulty behaviour depends on thread interleaving. Linus Torvalds had attempted a related fix in 2005, but it was reverted for hardware-specific reasons.
In practice, yes, where containers rely on kernel namespaces for isolation and share the host kernel. Root inside a container plus a kernel escalation generally means root on the host. The incident is one reason teams adopted seccomp profiles, user namespaces, read-only root file systems, and in high-risk cases hardware-isolated runtimes such as microVMs.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.