Khai thác dirtycow trên linux

Dirty COW (Dirty copy-on-write) is a computer security vulnerability of the Linux kernel that affected all Linux-based operating systems, including Android devices, that used older versions of the Linux kernel created before 2018. It is a local privilege escalation bug that exploits a race condition in the implementation of the copy-on-write mechanism in the kernel's memory-management subsystem. Computers and devices that still use the older kernels remain vulnerable.

The vulnerability was discovered by Phil Oester. Because of the race condition, with the right timing, a local attacker can exploit the copy-on-write mechanism to turn a read-only mapping of a file into a writable mapping. Although it is a local privilege escalation, remote attackers can use it in conjunction with other exploits that allow remote execution of non-privileged code to achieve remote root access on a computer. The attack itself does not leave traces in the system log.

The vulnerability has the Common Vulnerabilities and Exposures designation CVE-2016-5195. Dirty Cow was one of the first security issues transparently fixed in Ubuntu by the Canonical Live Patch service.

It has been demonstrated that the vulnerability can be utilized to root any Android device up to (and excluding) Android version 7 (Nougat).

History[edit]

The vulnerability has existed in the Linux kernel since version 2.6.22 released in September 2007, and there is information about it being actively exploited at least since October 2016. The vulnerability has been patched in Linux kernel versions 4.8.3, 4.7.9, 4.4.26 and newer.

The patch produced in 2016 did not fully address the issue and a revised patch was released on November 27, 2017, before public dissemination of the vulnerability.

The Dirty COW vulnerability has many perceived use cases including proven examples, such as obtaining root permissions in Android devices, as well as several speculated implementations. There are many binaries used in Linux which are read-only, and can only be modified or written to by a user of higher permissions, such as the root. When privileges are escalated, whether by genuine or malicious means – such as by using the Dirty COW exploit – the user can modify usually unmodifiable binaries and files. If a malicious individual could use the Dirty COW vulnerability to escalate their permissions, they could change a file, such as /bin/bash, so that it performs additional, unexpected functions, such as a keylogger. When a user starts a program which has been infected, they will inadvertently allow the malicious code to run. If the exploit targets a program which is run with root privileges, the exploit will have those same privileges.

Remedies and recourse[edit]

At the dawn of its discovery, anyone using a machine running Linux was susceptible to the exploit. The exploit has no preventative work around, the only cure is a patch or running a newer version which is not vulnerable anymore. Linus Torvalds committed a patch on October 18, 2016, acknowledging that it was an old vulnerability he had attempted to fix eleven years ago. Some distributors provide patches, such as Canonical, who provided a live patch. In the absence of a patch, there are a few mitigation technologies including SystemTap, and very little security from SELinux or AppArmor. Antivirus software has the potential to detect elevated permissions attacks, but it cannot prevent the attack. When given the opportunity, the safest route is to upgrade the Linux kernel to the following versions:

Ban đầu, lỗi bảo mật này trong nhân của hệ điều hành Linux từng được một người dùng phát hiện ra từ 11 năm trước, nhưng từ đó tới nay lỗ hổng bảo mật này vẫn chưa được vá hoàn toàn và hiện tại vẫn có thể bị khai thác một cách dễ dàng.

Theo Red Hat, công ty cung cấp HĐH mã nguồn mở Red Hat Linux, lỗ hổng bảo mật kể trên nằm trong nhân của Linux, thuộc tiến trình quản lý RAM của hệ điều hành, một tài khoản user bình thường của máy có thể tận dụng lỗ hổng này để được cấp quyền ghi dữ liệu, tức là "nâng cấp" quyền hạn của user này lên mức cao hơn, có thể là tương đương với tài khoản Root.


Người gần nhất đề cập tới lỗ hổng bảo mật này là Phil Oester, một chuyên gia bảo mật, anh nói "Lỗ hổng này rất dễ để khai thác, không bao giờ bị thất bại (khi muốn tấn công) và đã tồn tại từ bao nhiêu năm qua". Phil đã phát hiện ra lỗi kể trên khi ghi lại toàn bộ những dữ liệu đầu vào HTTP, khai thác lỗ hổng và thử test nó trên một giao diện giả lập sandbox.

Lỗ hổng bảo mật Linux kể trên là CVE-2016-5195, hay còn được gọi với tên khác là Dirty Cow đã tồn tại trên nhân của HĐH mã nguồn mở Linux từ năm 2005. Ở thời điểm đó, Linux Tovalds đã từng viết bản vá cho lỗ hổng (patch) này xong xuôi. Tuy vậy, trong một bản cập nhật Linux 2 năm sau đó, bản patch của Tovalds đã bị loại bỏ, kết quả là lỗ hổng vẫn còn đó từ năm 2007 như chưa từng được biết tới, mãi cho tới ngày nay khi Phil Oester một lần nữa nhắc tới nó.

Hiện tại Red Hat đã tung ra bản vá cho lỗ hổng này cho phiên bản Linux của họ. Nhưng vì Linux là nhân hệ điều hành mở, vốn sẽ được tùy biến thành nhiều phiên bản khác nhau, do đó Phil Oester khuyến cáo người dùng nên kiểm tra hệ thống của mình và tiến hành nâng cấp các bản vá để khắc phục lỗ hổng Dirty Cow này, nhằm giữ cho hệ thống được an toàn hơn.

Theo V3; ảnh: Maciek905​