EASY7

CVE-2019-13272 local root exploit 본문

보안 공부/취약점 실습

CVE-2019-13272 local root exploit

E.asiest 2019. 8. 3. 11:30

local root exploit

kernel/ptrace.c에 ptrace_link가 ptrace 관계를 생성하는 프로세스의 비밀정보를 잘못처리하는 것이다.

부모-자식 프로세스 관계를 이용해 local 계정이 root 권한을 얻게한다. 부모가 권한을 잃고 execve를 호출한다(?)

이러한 이유는 object lifetime와 부적절한 ptrace 관계이다. 

이 취약점을 해결하기위해 SELinux deny_ptrace가 사용해야할 것이다.

더보기

Linux local root exploit.

In the Linux kernel before 5.1.17, ptrace_link in kernel/ptrace.c mishandles the recording of the credentials of a process that wants to create a ptrace relationship, which allows local users to obtain root access by leveraging certain scenarios with a parent-child process relationship, where a parent drops privileges and calls execve (potentially allowing control by an attacker). One contributing factor is an object lifetime issue (which can also cause a panic). Another contributing factor is incorrect marking of a ptrace relationship as privileged, which is exploitable through (for example) Polkit's pkexec helper with PTRACE_TRACEME. NOTE: SELinux deny_ptrace might be a usable workaround in some environments.

https://github.com/bcoles/kernel-exploits

Linux local root exploit.

In the Linux kernel before 5.1.17, ptrace_link in kernel/ptrace.c mishandles the recording of the credentials of a process that wants to create a ptrace relationship, which allows local users to obtain root access by leveraging certain scenarios with a parent-child process relationship, where a parent drops privileges and calls execve (potentially allowing control by an attacker). One contributing factor is an object lifetime issue (which can also cause a panic). Another contributing factor is incorrect marking of a ptrace relationship as privileged, which is exploitable through (for example) Polkit's pkexec helper with PTRACE_TRACEME. NOTE: SELinux deny_ptrace might be a usable workaround in some environments.

https://github.com/bcoles/kernel-exploits

#용어 정리

ptrace (process trace) 

리눅스나 유닉스에서 시스템호출로 프로세스가 어떤식으로 움직이고, 어떤식으로 데이터를 읽고 쓰는지, 어떤 에러를 내는지 추적을 하기위해 마련된 시스템 콜이다. 보통 디버그를 위해 사용된다. 

 

 

관련 CVE정보

CVE-2019-13272

 

 

 

취약한 OS 버전

// - Ubuntu 16.04.5 kernel 4.15.0-29-generic
// - Ubuntu 18.04.1 kernel 4.15.0-20-generic
// - Ubuntu 19.04 kernel 5.0.0-15-generic
// - Ubuntu Mate 18.04.2 kernel 4.18.0-15-generic
// - Linux Mint 17.3 kernel 4.4.0-89-generic
// - Linux Mint 18.3 kernel 4.13.0-16-generic
// - Linux Mint 19 kernel 4.15.0-20-generic
// - Xubuntu 16.04.4 kernel 4.13.0-36-generic
// - ElementaryOS 0.4.1 4.8.0-52-generic
// - Backbox 6 kernel 4.18.0-21-generic
// - Parrot OS 4.5.1 kernel 4.19.0-parrot1-13t-amd64
// - Kali kernel 4.19.0-kali5-amd64
// - Redcore 1806 (LXQT) kernel 4.16.16-redcore
// - MX 18.3 kernel 4.19.37-2~mx17+1
// - RHEL 8.0 kernel 4.18.0-80.el8.x86_64
// - Debian 9.4.0 kernel 4.9.0-6-amd64
// - Debian 10.0.0 kernel 4.19.0-5-amd64
// - Devuan 2.0.0 kernel 4.9.0-6-amd64
// - SparkyLinux 5.8 kernel 4.19.0-5-amd64
// - Fedora Workstation 30 kernel 5.0.9-301.fc30.x86_64
// - Manjaro 18.0.3 kernel 4.19.23-1-MANJARO
// - Mageia 6 kernel 4.9.35-desktop-1.mga6
// - Antergos 18.7 kernel 4.17.6-1-ARCH

 

점검 방법

linux 커널 정보 확인하는 법

$ uname -r

실행 환경 Kali kernel 4.19.0-kali5-amd64이 있다!

 

 

보안 조치 방법

 

 

 

실습

실습 환경

Kali

 

1. git에 나온 가능 linux 확인하기

linux 커널 정보 확인하는 법

$ uname -r

실행 환경 Kali kernel 4.19.0-kali5-amd64이 있다!

 

 

2. 컴파일하기

$ gcc -s CVE-2019-13272.c -o pwned

CVE-2019-13272.c
0.01MB

 

3. 실행하기

$ ./pwned

root 권한 획득

*해결방법

패치가 나와야하나??

deny_ptrace을 검색해봤는데 설정파일이 나오지 않는다....??

https://danwalsh.livejournal.com/49564.html

 

 

*궁금증

gcc는 root만 사용할 수 있는데 일반계정에서 컴파일하는 법 

root권한으로만 할 수 있는 것은?

이 툴의 원리는? 

CentOS에서는 컴파일이 안된다. 그 이유가 뭘까.

CentOS 컴파일 오류

 

 

참고자료

참고

CVE 정보 

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-13272

 

Demo

https://asciinema.org/a/6HFa1zk4bZKFjXDcr5LKnyiH1

 

source code

https://github.com/bcoles/kernel-exploits/blob/master/CVE-2019-13272/poc.c

 

 

'보안 공부 > 취약점 실습' 카테고리의 다른 글

Exploit Database 사용법  (0) 2019.08.03
scapy  (0) 2019.08.03
Metasploit Framework 메타스플로잇 기초  (0) 2019.08.03
WebDav 취약점  (0) 2019.08.03
FOCA를 이용한 정보 수집  (0) 2019.08.03
Comments