A new tool allows Mac OS X attackers with root OS access to easily steal the keychain password data of logged in users and reinforces the dangers of granting administrative privileges to applications without serious consideration.
The tool is called keychaindump and was created by Finnish software developer Juuso Salonen, the author of the Radio Silence firewall for Mac OS X.
The Mac OS X keychain is a password management system designed to allow the storing and accessing of user passwords for various types of accounts and applications in a secure manner.
“The passwords in a keychain file are encrypted many times over with various different keys,” Salonen said in a blog post. “Some of these keys are encrypted using other keys stored in the same file, in a russian-doll fashion.”
“The [master] key that can open the outermost doll and kickstart the whole decryption cascade is derived from the user’s login password using PBKDF2 [a cryptographic key derivation function],” Salonen said Thursday in a blog post.
Salonen’s keychaindump uses pattern recognition techniques to scan the memory space of “securityd” — the process that handles keychain operations in Mac OS X — and locate the keychain master key.
Keychaindump doesn’t exploit a vulnerability in Mac OS X or securityd. However, it takes advantage of Apple’s design choice to automatically unlock users’ keychains when they log into their accounts and store the corresponding master keys in memory for easier access.
This is not necessarily a bad design decision and implementing the keychain access mechanism in a different manner — for example, by asking the user to input their keychain password every time when an application needs to access keychain data — wouldn’t have ultimately impacted the ability of attackers with root access to steal keychain data. After all, it’s a well known fact that you can do pretty much anything on an operating system from the root (administrator) account.
“News flash, root can also format your hard drive, news at 11,” renowned Apple hacker Charlie Miller said on Twitter when learning about Salonen’s tool.
“What I described was not a security vulnerability in OS X, as it requires root access to begin with,” Salonen said Friday via email. “And, as most developers know, root can do *anything*.”
What sets keychaindump apart from other possible root-level password stealing methods is the speed and ease with which it can achieve its goal.
Salonen hopes that the tool will be of use to authorised penetration testers who wish to quickly grab passwords in a post-system-compromise scenario.
However, the tool can just as well be incorporated in malware, since its source code is freely available online.
Mac malware running as root is not an uncommon occurrence, Lysa Myers, virus hunter at Mac antivirus vendor Intego, said Friday via email. “The two most common ways to achieve root access is by way of exploits and social engineering. Social engineering being far and away the most common, as it’s often fairly easy to trick someone.”
Social engineering in this context consists of the malware program masquerading as a legitimate program and asking the user to grant it administrative access.
“I’m personally worried about how easy it is to gain root on a Mac,” Salonen said. “Not because of vulnerabilities, but because you end up doing it all the time in day-to-day use.”
“For example, I just browsed my /Applications folder, and noticed that a majority of my apps are owned by root,” Salonen said. “Even non-critical stuff like IRC clients, video players, games, tiny helper apps, even the official Twitter client. Each of those installers had root access at some point. I don’t remember explicitly giving Twitter root access. I just remember running a typical installer. It’s scary.”
Mac malware authors have already shown an interest in keychain data. “One threat called DevilRobber discovered last year used a script to harvest passwords,” Myers said. “The main trick in that instance was that it would automatically validate the system dialog box that prompts the user to allow their keys to be exported.”
There isn’t much Apple can do to ultimately stop attackers with root access from stealing credentials stored in a user’s keychain. However, there are some methods to make it a bit harder.
Apple could, for example, better obfuscate the keychain master password key in memory and make it harder for a tool like keychaindump to find it and extract it, Arnaud Abbati, a malware analyst at Intego, said Friday.
Apple did not return a request for comment regarding its keychain design choices or the security implications of Salonen’s tool.