How did I find the Apple Remote Desktop bug? - CVE-2013-5135
The Apple Remote Desktop screensharingd service logged the username without sanitising it, allowing a format string attack. An attacker could crash the service and potentially execute code, though the author did not achieve a working exploit.
Inspired by the Windows Remote Dektop bug (CVE-2012-0002)I created a simple network protocol fuzzer. This is a dumb fuzzer that only changes every single byte value from 0 to 255:
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 screensharingd binary passed the unsanitised username directly as a format string argument to syslog().
Impact
An attacker could crash the screensharingd service and potentially execute arbitrary code, though the author did not achieve a working exploit due to null bytes, limited buffer space, and a non-executable stack.
What the attacker needed
Network access to the ARD service; ability to send authentication requests
The fix
The vulnerability was fixed in Apple Remote Desktop 3.7, as indicated by the CVE reference.
How it was found
- Create a simple network protocol fuzzer that changes each byte of the captured VNC authentication traffic.
- Run the fuzzer against the Apple Remote Desktop service and monitor the secure.log and crash reports.
- Observe a crash in __vfprintf and use a debugger to see the call stack leading to syslog().
- Use IDA Pro to locate the authentication failure code and confirm the username is passed unsanitised to syslog().
- Test by authenticating with a VNC client using a username containing format specifiers and check secure.log for the crash.
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.
A format string bug happens when a program puts user input directly into a formatting function like printf or syslog. If the input contains special percent signs, the program can be tricked into reading or writing memory it should not. Here, the username was passed to syslog without cleaning, so a crafted username could crash the service and maybe let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.