Tool allows Mac OS X hackers with root access to easily extract keychain data

Developer creates tool to easily decrypt the keychain data of local Mac OS X users from the root account

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 Wednesday 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 Wednesday 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 Thursday 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 authorized 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 Thursday 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 Thursday.

Apple did not return a request for comment regarding its keychain design choices or the security implications of Salonen's tool.

Join the CSO newsletter!

Error: Please check your email address.
Show Comments

Featured Whitepapers

Editor's Recommendations

Solution Centres

Stories by Lucian Constantin

Latest Videos

  • 150x50

    CSO Webinar: The Human Factor - Your people are your biggest security weakness

    ​Speakers: David Lacey, Researcher and former CISO Royal Mail David Turner - Global Risk Management Expert Mark Guntrip - Group Manager, Email Protection, Proofpoint

    Play Video

  • 150x50

    CSO Webinar: Current ransomware defences are failing – but machine learning can drive a more proactive solution

    Speakers • Ty Miller, Director, Threat Intelligence • Mark Gregory, Leader, Network Engineering Research Group, RMIT • Jeff Lanza, Retired FBI Agent (USA) • Andy Solterbeck, VP Asia Pacific, Cylance • David Braue, CSO MC/Moderator What to expect: ​Hear from industry experts on the local and global ransomware threat landscape. Explore a new approach to dealing with ransomware using machine-learning techniques and by thinking about the problem in a fundamentally different way. Apply techniques for gathering insight into ransomware behaviour and find out what elements must go into a truly effective ransomware defence. Get a first-hand look at how ransomware actually works in practice, and how machine-learning techniques can pick up on its activities long before your employees do.

    Play Video

  • 150x50

    CSO Webinar: Get real about metadata to avoid a false sense of security

    Speakers: • Anthony Caruana – CSO MC and moderator • Ian Farquhar, Worldwide Virtual Security Team Lead, Gigamon • John Lindsay, Former CTO, iiNet • Skeeve Stevens, Futurist, Future Sumo • David Vaile - Vice chair of APF, Co-Convenor of the Cyberspace Law And Policy Community, UNSW Law Faculty This webinar covers: - A 101 on metadata - what it is and how to use it - Insight into a typical attack, what happens and what we would find when looking into the metadata - How to collect metadata, use this to detect attacks and get greater insight into how you can use this to protect your organisation - Learn how much raw data and metadata to retain and how long for - Get a reality check on how you're using your metadata and if this is enough to secure your organisation

    Play Video

  • 150x50

    CSO Webinar: How banking trojans work and how you can stop them

    CSO Webinar: How banking trojans work and how you can stop them Featuring: • John Baird, Director of Global Technology Production, Deutsche Bank • Samantha Macleod, GM Cyber Security, ME Bank • Sherrod DeGrippo, Director of Emerging Threats, Proofpoint (USA)

    Play Video

  • 150x50

    IDG Live Webinar:The right collaboration strategy will help your business take flight

    Speakers - Mike Harris, Engineering Services Manager, Jetstar - Christopher Johnson, IT Director APAC, 20th Century Fox - Brent Maxwell, Director of Information Systems, THE ICONIC - IDG MC/Moderator Anthony Caruana

    Play Video

More videos

Blog Posts