118 points · by walterbell · 10y ago · 52 comments
If you execute "security dump-keychain -d login.keychain":
1. If the keychain is unlocked (the keychain is unlocked by default after logging in, and you can check that by opening the Keychain Access app) a SecurityAgent window opens, and you must click the Allow button to dump the keychain. That cannot be scripted in an installation of a recent version of OS X which is not misconfigured.
2. If the keychain is locked (for example, by clicking the padlock in the Keychain Access app to lock it), it asks you for your user password, just like the Keychain Access app does.
We haven't been able to figure out why some users are prompted and others are not.
If you let someone untrusted (!) log in remotely to your computer with your user account or you give it to someone while your user is logged in it's your own fault if your keys get stolen. You should use a guest account with restricted privileges or a separate machine.
It's not much different on Linux, if you use Gnome-Keyring (used by default in Ubuntu and others) you can also get the passwords easily, in plain text [1].
Not sure about Windows, but you can most likely get to the passwords without installing anything as well if you're already logged in as the current user. If you're allowed to run executables, there are quite a few already [2].
[1] https://blog.schmichael.com/2008/10/30/listing-all-passwords...
The only way this should be possible on the Mac is if a logged in user physically at the computer selects "Allow" or "Always allow" for each security dialog that appears. Remote sessions are not permitted to do this.
Security dialogs cannot be scripted under normal circumstances (the AppleScript given in the article simply doesn't work). I suspect it might be possible to do highly dangerous things like blessing the "System Events" tool as an Accessibility tool in the Security System Prefs Pane (which would allow it to send events to security dialogs) but I'm not totally sure that's possible and in any case, I don't think that's happening here. I think the author is simply mistaken or has clicked "Always allow" in the past and doesn't realize that this setting is still active.
I have dug through security preferences extensively and can't see what setting could be changed or updated to disallow this function.
I've updated the article to address and respond to some of the criticisms and feedback.
tell process "SecurityAgent"
click button "Allow" of group 1 of window 1
I'm pretty certain this is not possible in any recent version of OS X.The main concern I have is the inconsistency that this command does not request a password while the keychain access app, as far as I know, does request one.
Apple has been aware about their security behavior here at any rate.
Maybe there is an easy way to decrypt them using some other information in the output, but I haven't looked further.
> error "System Events got an error: Can’t get group 1 of window 1 of process \"SecurityAgent\". Invalid index." number -1719 from group 1 of window 1 of process "SecurityAgent"
You're not supposed to be able to script SecurityAgent – and it doesn't work on my computer. Specifically, security windows should appear empty when read by other processes.
https://developer.apple.com/legacy/library/documentation/Dar...
>dump-keychain [-adhir] Dump the contents of one or more keychains.
-a Dump access control list of items
-d Dump (decrypted) data of items
-i Interactive access control list editing mode
-r Dump raw (encrypted) data of items
I'm not at my Mac so can't test what it means by "dump decrypted", but I don't think it dumps all data in plain-text as the article suggested. I am curious if the keychain was unlocked when they did it for whatever reason.I still question why such an ability exists through terminal without more control, but it's not quite as described.
edit: was very unclear I was posting a snippet of the actual command. fixed
I am a little surprised it doesn't ask foe the keychain password.
Instead of what? What do you propose would be better?
Which IMO is purely negligently
And unless you want to type in a password every time you need to access any of these stored passwords (which would nearly defeat the purpose), then the application or OS needs to keep that password and/or key in memory somewhere.
At that point, I would trust an application that runs with privileges that not even root can get (thanks to 10.11's rootless mode) much more than any other application, even given the eventual security flaw.
This severely reduces the attack surface to only the keychain application itself and to the component that enforces the privileges, whereas in other cases any root-exploit will cause you to lose your passwords.
In the year of 10.11's existence, no security flaw has been found in either system integrity protection (= rootless mode) nor in keychain (the bug listed here isn't a bug. if you ask keychain to give you the password, it will have to give you the password or there would be zero point in even storing it in the first place)