Privilege Escalation via Cron System in macOS
A non-root user was able to write to any file on the system that was not SIP-protected but the resulting file would not be root-owned, even if it previously was. This presented an interesting challenge for privilege escalation - how would you exploit this to obtain root access? The obvious first attempt was the sudoers file but sudo is smart enough not to process it if the file isn't root-owned so that didn't work. The cron system in macOS does not care who the crontab files are owned by. Getting root was a simple case of creating a crontab file at /var/at/tabs/root with a 60-second cron line, eg: * * * * * chown root:wheel /tmp/payload && chmod 4755 /tmp/payload and then waiting for it to execute.