Skip to content
Access control Write-up Advanced

OS X 10.10 DYLD_PRINT_TO_FILE Local Privilege Escalation Vulnerability

The DYLD_PRINT_TO_FILE environment variable was handled directly in dyld's main function without the usual restricted-binary safeguards, so SUID root binaries would open or create an arbitrary file as root and leak the writable file descriptor to child processes. An unprivileged local user could then append to or overwrite root-owned files, including SUID binaries, to gain root privileges.

sektioneins.de

Published on sektioneins.de

The DYLDPRINTTOFILE environment variable can be used for local privilege escalation in OS X Yosemite.

Stefan Esser, on sektioneins.de

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The new environment variable was parsed in dyld's main function instead of the routine that strips dangerous environment variables for restricted binaries, and the opened log file descriptor was not marked close-on-exec.

What the attacker needed

Local access to OS X 10.10.x; ability to run SUID root binaries

The fix

Apple fixed it in the OS X 10.11 beta by moving the handling into the function that automatically protects restricted binaries.

How it was found

  1. Set the EDITOR variable to a harmless program and DYLD_PRINT_TO_FILE to a path in the root directory, then run crontab -e.
  2. Check that the named file now exists in the root directory owned by root.
  3. Run a SUID binary such as su with DYLD_PRINT_TO_FILE set to a target file.
  4. In the spawned shell, write to the leaked file descriptor to append data to the root-owned file.
  5. Use a small program as EDITOR that clears the append flag and seeks to the start, then overwrite a SUID binary with a root shell.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

On macOS, some programs run with extra powers (SUID root) so they can do privileged tasks. A new setting let those programs open any file as the powerful root user and pass the open file handle to programs they start. A normal user could then write into that file, even replacing a privileged program, and become root.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.