Rapid7 Vulnerability & Exploit Database

macOS cfprefsd Arbitrary File Write Local Privilege Escalation

Back to Search

macOS cfprefsd Arbitrary File Write Local Privilege Escalation

Disclosed
03/18/2020
Created
09/05/2020

Description

This module exploits an arbitrary file write in cfprefsd on macOS <= 10.15.4 in order to run a payload as root. The CFPreferencesSetAppValue function, which is reachable from most unsandboxed processes, can be exploited with a race condition in order to overwrite an arbitrary file as root. By overwriting /etc/pam.d/login a user can then login as root with the `login root` command without a password.

Author(s)

  • Yonghwi Jin <jinmoteam@gmail.com>
  • Jungwon Lim <setuid0@protonmail.com>
  • Insu Yun <insu@gatech.edu>
  • Taesoo Kim <taesoo@gatech.edu>
  • timwr

Platform

OSX

Architectures

x64

Development

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/osx/local/cfprefsd_race_condition
msf exploit(cfprefsd_race_condition) > show targets
    ...targets...
msf exploit(cfprefsd_race_condition) > set TARGET < target-id >
msf exploit(cfprefsd_race_condition) > show options
    ...show and set options...
msf exploit(cfprefsd_race_condition) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security

;