12 ms·
OSX password script for everyone to know
- paupino_masano 14y agoAdmittedly I was a bit shocked to see my passwords start pumping out: all I needed to do was click "Allow" and away it went. Why would keychain remain unlocked? Why doesn't that command need sudo? This seems like a pretty decent security flaw to me...
- robmil 14y agoIs this sarcasm? You clicked "Allow"; what would you expect of an application to which you granted access to your keychain, other than for that application to thereby gain access to your keychain?
- mcrider 14y agoYou don't need a password to press 'allow'. It is still very much a security concern.
- Karunamon 14y agoWhy is someone who is not you logged in using your account with the ability to click that button in the first place? Layering security on the user account after login tends to annoy the hell out of people. Ask any users you know what they think of Windows 7/Vista's UAC.
- DanBC 14y agoI agree with your first sentence. I sort of agree with the people saying this behaviour is by design and is not a serious security flaw. > Layering security on the user account after login tends to annoy the hell out of people. Ask any users you know what they think of Windows 7/Vista's UAC. But this isn't another OS. This is OS X, which is built on BSD, and BSD is a secure OS. Another question to ask would be "Ask any users you know what they think of sudo". I like the article. It's not sensationalist. It's not dramatic. It's just saying "Hey, do this! Surprised? This is why you need to be careful with your account and your password." That seems reasonable to me. Many people Using OS X are not from a Unix background. They have never used a BSD before. They don't really have the security stuff ingrained. Gentle reminders from time to time are a good thing.
- grecy 14y agoYou need a password to be able to press allow.
- mjhall 14y agoTo add to grecy's comment: Your login Keychain is usually unlocked - it's encrypted with a key derived from your password that's held in memory from when you log in. You can lock your login Keychain (or any other) from Keychain Acccess (/Applications/Utilities) or from the security menu bar item (if you have it added) and you'll be asked for the password rather than asked to "allow" it.
- wamatt 14y agoAhh ok, subtle distinction. Thanks for clearing that up. :)
- geofft 14y agoWhy would it need sudo? If that were the case, then every web browser and every IM client and everything else on your computer with a password would need sudo. You're telling your computer to save your passwords and give them back to you later. You shouldn't be surprised when it gives them back to you later.
- lambda 14y agoSo, generally each application needs to be authorized separately. I should have to type my password to allow this application to access my passwords. If I can just click "allow" with no password, then so can anyone else trivially with Terminal access. If I go into Keychain access, and ask to see a password, it prompts for my master password before showing it to me. This should too.
- eddieplan9 14y agoFrom KeyChain's point of view, this command-line utility, /usr/bin/security, is no different from other GUI applications like Mail.app and Safari.app that relies on KeyChain to supply remembered passwords. If you expect KeyChain to prompt you for your master password when /usr/bin/security asks KeyChain for passwords, then you will be prompted every time Mail.app checks your email. Actually you can configure KeyChain to do just that: just set the keychain to lock after 0 minutes of inactivity. But there is always the tradeoff between security and convenience. And when you give away physical access and a logged-in session away to a malicious user, offering protection will require a lot of inconvenience.
- corwinstephen 14y agoI'm totally going to use this for way more bad than good.
- brockrockman 14y agoHardly a security flaw. How do you expect Safari/Chrome autofill the same passwords? And after the password is auto-filled any JavaScript can access the input's value attribute. I use this in my .emacs so Emacs can grab passwords from Keychain, but the same approach would work in bash too: (defun find-keychain-password (host) () (condition-case nil (let ((passstr (second (split-string (first (process-lines "/usr/bin/security" "find-internet-password" "-gs" host)) ": ")))) (substring passstr 1 (1- (length passstr)))) (error nil)))
- jdechko 14y agoI'm inclined to agree. It looks like this is the same "hack" detailed last week, though through a terminal command instead of an application. As we learned last week, by default, OS X is set to never lock the keychain once it is logged in. It's a conscious choice of default set by Apple. If you care about tighter security, just change the autolock time or use separate keychains.
- Bakkot 14y agoNo, last week's was root only, operated by searching through RAM for various keys, and was notable for displaying passwords for every logged-in user, which this will not do.
- sitharus 14y agoThat's a handy function! Thanks for sharing :)
- stuartd 14y agoI run as a non-admin user on Mountain Lion (stops the kids messing stuff up) and it sometimes has unexpected benefits - like in this case, when I run security dump-keychain -d ~/Library/Keychains/login.keychain in terminal the output is most definitely not plain text even after I press 'Allow' - see http://pastebin.com/TH63R9sM http://pastebin.com/TH63R9sM for a sample
- geofft 14y agoOh cool, is that your client certificate's private key?
- stuartd 14y agoAs I said, edited..
- eblume 14y agoYou should probably delete that, I'm thinking that that's a private key. It's not a 'password' but it's still a secret, and you just pastebin'ed it for everyone. But I'm just guessing -- I don't know too well what a private key would look like in this format.
- ninjac0der 14y agoApple doesn't introduce security flaws. They are far to big and awesome for that. This is a clear compromise between security and user experience....
- kreek 14y agoLocking the keychain works until you unlock it from another app. If you enter your keychain password for Mail app or for a web password it becomes unlocked for the terminal command. Which is unexpected behavior as from within keychain, even if it is unlocked, you must reenter your password if you want to see a saved password.
- jtokoph 14y agoYou may want to setup autolocking: 1. Launch "Keychain Access". 2. Right click on "login" keychain. 3. Click "Change Settings for Keychain 'login'". 4. Check the "Lock after:" box. 5. Change the minutes of activity to whatever you want. You have the option of auto-locking after zero minutes of inactivity.
- eblume 14y agoI was about 5 minutes in to the docs to set up a quicksilver task to do this - thanks for helping me avoid re-inventing the wheel. Yours was the better 'hack'. ;)
- mkmk 14y agoJust in case anybody else doesn't see the 'login' keychain: the square button with a triangle in the bottom left corner shows and hides an additional list of keychains
- ammmir 14y agoor using command line (lock default keychain on sleep and after 30 min): $ security set-keychain-settings -lut 1800
- tlrobinson 14y agoI tried this, and quickly got annoyed with having to enter my password every time iCal tried to sync. It would be better if you could set it to require a password every time a previously unauthorized app requests access to a Keychain item.
- draebek 14y agoI think I had this same problem with Mail.app. I "solved" it by creating a separate keychain that just locks on sleep, but doesn't timeout, and moving my Mail passwords into that keychain. Presumably the same thing would work for iCal.
- leejoramo 14y agoI ran this command and for at least the first 10 items, I was prompted by a GUI dialog to allow the export of the keychain item. (I have close to 2,000 items in my keychain, so it is a small sample.) I think that this is more of a lesson to: 1) Have reason able auto locking time outs setup via the Keychain and Screen Saver 2) when Keychain Access prompts you to access info that you should normally click "Allow" and not "Always Allow".
- aidos 14y agoBut if you click in allow you could actually see the protected info, right? No password required.
- aidos 14y agoThe reason this is strange behaviour is that when you try to access private info from within keychain you have to enter your user password each time. Using this command you just need to click on the allow button. The keychain only allows applications that you authorize to access a given password, right? So for example, when I upgrade Transmit, it needs to ask for my permission to access the passwords again. Does that give it access to everything or just a specific password / set of passwords?
- sitharus 14y agoAn application can only read passwords you've specifically allowed it to. When you upgrade Transmit it only gets access to that subset. If you're curious go to Keychain Access, double click an item and look at the Access Control tab. You can even force password entry there if you want extra security on certain items.
- jasomill 14y agoPerhaps, but the Transmit developers could actually even use code signing to get Keychain to recognize multiple versions (new ones, but also alternative builds such as might be distributed by the Mac App Store) as the "same" application (Google "designated requirements"). Either way, though, barring security bugs (including unnecessarily permissive designated requirements being used by other apps), this should only give Transmit access to passwords you've specifically authorized for Transmit. Of course, if Transmit were malicious and one of these passwords happened to be your local login password...
- dhruvtv 14y agoHow is this command line method any different/better than opening Keychain Access, clicking on each entry and checking 'Show Password'?
- sitharus 14y agoShow Password prompts for the keychain password. This just prompts you to allow without password entry.
- tlrobinson 14y agoIs 1Password more or less secure than Keychain? If my 1Password is unlocked can any application get passwords out of it?
- sitharus 14y agoThat's an interesting question. 1Password isn't as integrated as the Keychain, but in both cases you have to manually approve access. 1Password is more portable though - Keychain is only useful in MacOS X.
- sil3ntmac 14y agoKeychain uses AES256 so it's about as reasonably secure of a single-password solution as you can get (given you use it correctly). I would assume 1Password is equivalently secure.
- tlrobinson 14y agoI'm less worried about the crypto algorithms used than what's available decrypted and when.
- klodolph 14y agoThe choice of encryption algorithm only lets us point out which systems are broken, not which ones are secure. A secure system could never use ROT13, but a broken system could definitely use AES256.
- dkokelley 14y agoFirst of all, if someone has unauthorized physical access to your device, you're pretty hosed. Especially if they happen to have a current logged in session. Forget passwords, they have cookies and mail.app and bookmarks. Second, if you must lend your computer to an untrusted person, use the Guest session. I just tried this and confirmed that there is no immediately obvious way for a person logged in to a guest session to access my keychain. Knowing this, I will rewrite the opening line to the article. Original line: "Here’s a reason why you shouldn’t let anyone use your computer." My revised line: "Here's a reason why you shouldn't let [untrusted persons] use [a non-guest session on] your computer."
- FlukeATX 14y agoWhat do you mean "Forget passwords, they have cookies..."? Since when is having a cookie better than having the password that can give you the cookie anyway?
- shadowflit 14y agoIf you have two factor authentication but leave yourself signed in, a password alone will not get an intruder into your account, but a cookie will.
- klodolph 14y agoSome web sites will require you to login again if your IP address changes, no matter what cookies you have. Additionally, the cookie expires. For these websites, the password is much better.
- dkokelley 14y agoshadowflit made a good point about two-factor authentication. I would also add that by having cookies (and hence a presumed established session with you bank, email provider, or social network) you bypass one of the steps to get what you presumably want: access. I mean to point out that there is no reason to run this script if you already have physical access to a computer with the target's account logged on. You already have the extra access you need.
- sil3ntmac 14y agoUgh, the people I work with (I work for a security firm) consider this a "hack" as well. This is expected behavior! How do you expect your passwords to autofill across browsers? It is called the login keychain for a reason. If someone has access to your user account, and your user account has associated web passwords that can be summoned without re-entering your login password, then the logical conclusion is that your web passwords are not safe. However, Keychain Access is perfectly secure as a dead-simple manual password manager. Just create a new keychain (I call mine "webpasses"), give it a password different than your login password, and manually save your web passwords in that. Yes you have to open Keychain Access every time you want to save (or copy the plaintext of) a password. Yes it's a bitch. But if you save your passwords in the correct format (description=website URL, username=website username) then Chrome and Safari will find it, ask for your "webpasses" keychain password, and autofill, no questions asked. Bonus points because you can save your new keychain in your dropbox and use it across multiple (osx) machines. I store all my credit card numbers in one keychain file, everything is AES encrypted IIRC so it's as good a solution as any as far as "one-password-auth" goes. [/rant] (note: I chose this solution because I am paranoid -- er, security conscious. The average user will NOT want to enter a password anytime he/she wants to autofill, and there's really no way to do this in a secure manner) EDIT: grammar
- ghayes 14y agoI guess a bigger question is why don't we use challenge/response authentication for websites? This way, a program like keychain could answer challenges without ever exposing plain-text passwords.
- dustingetz 14y agoAm I the only one who read your post and said "huh"? Don't mean to have a naive reply, but this is new to me.
- izakage 14y agoThe server sends a challenge to the client. The client computes response = f(challenge, password), and sends the response. Then the server compares the response with its own computation of f(challenge, password). Since f is some type of hash function, we can assume that the client knew the actual password, as it would have been too hard computationally to come up with the correct response without it. In such a scheme, the keychain can do the computation and the password never leaves the keychain. We can even go as far as to have the keychain be separate hardware (eg USB dongle), so the password never even has to exist on the client's computer at all.
- induscreep 14y agoooh look I can access my .config folder on linux.
- an0nym0usc0ward 14y ago.
- induscreep 14y agoooh look I can access my .config folder on linux.
- delinka 14y agoOr maybe, just maybe, you should never let random people use your computer under your account. Create an account for randoms, switch users before loaning them the keyboard.
- javajosh 14y agoWhile it is shocking to see your passwords scroll by in plaintext, a careful consideration of how to fix the problem, one realizes that the offered solution really isn't good enough. Many applications require your passwords in order to run, and the Keychain is the way OSX apps get those passwords. After a little thought, there are two solutions. First, and best, is to log out, and let your guest use a guest account. Or second, watch over the persons shoulder (which is probably a good idea anyway for the security conscious.) But, personally my biggest concern is that it highlights how trivial it is for locally installed software to access my other passwords! It means that all of my passwords are only as protected as my least-trusted local app. And I have to say, my least trusted app is pretty untrusted. The only saving grace is that OSX asks me if I want to allow an app to access that password.
- zx2c4 14y agoAlternatively, it might be worthwhile to switch from using Keychain to using pass, a far better and simpler alternative: http://zx2c4.com/projects/password-store http://zx2c4.com/projects/password-store
- javajosh 14y agoit appears that this is self-promotion, but that's a nice-looking tool. it does look a little disruptive to my workflow (I suggest doing a screencast demonstrating some real world scenarios like periodically checking ical or gmail). and also, unique, not widely used (and not widely audited) security software seems like taking a pretty big risk. not really sure what you can do about that, since it's kind of a chicken and egg problem. but open sourcing it would help get the ball rolling.
- zx2c4 14y ago> it appears that this is self-promotion no, just trying to help you out by giving you my software. > but open sourcing it would help get the ball rolling. it is open source. what made you think otherwise? > and not widely audited it has been audited by security professionals.
- droithomme 14y agoKeychain Access and the general security model is poor. There should be a way for web passwords that are saved from a browser to be restricted for use from a set of authorized browsers only, without also allowing any random program from just grabbing the plaintext. From what I observe using this system, once you lock the entire keychain, then you have to unlock and relock it everytime you use a web password, or if you forget to relock, after authorizing one time access from the browser popup, it unlocks the whole keychain for the entire system. Unlocking my throwaway yahoo junk mail account in Safari should not also unlock the password to my banking account across the whole system. This is not the best design and those who say "works as designed", in my opinion, are suffering from myopic tunnel vision where they assume a current design is the only possible design.
- klodolph 14y ago1) Open Keychain access. 2) Select a keychain item (a password) and double-click it. 3) Click on the Access Control tab. You can choose which applications can access that particular password. I think there's also a group system, and there's a group called "InternetAccounts", but most of the passwords I see have an access list (which I haven't modified) that only includes one application, usually Safari or Mail, but I also see "NetAuth" and "NetAuthSysAgent" for passwords I use for file sharing. You can also make it so keychain access requires you to type the keychain password in every time a particular password is accessed, and you can also put passwords in separate keychains that use different passwords.
- droithomme 14y agoI am aware of that. Let's look at Mail passwords - Mail is the App with designated access on that pane. Now, if the entire Keychain is unlocked, Mail can access it when I check email. If the entire Keychain is locked, it asks for permission to use it. If I give permission, the entire Keychain is unlocked and left unlocked. It's not only access to Mail that is granted when Mail asks for validation. The entire keychain is unlocked. Some claim to just keep their Keychain locked. People who say they keep theirs locked all the time, do they really give a password every single time they check their mail during the day, and then immediately afterwards open Keychain Access and relock it? That's the workflow required to keep the Keychain locked. Perhaps it works OK if one uses another computer for email and internet use. If one uses email and site logins on their Mac, one either has to retype their password every single time, and every single time go open Keychain and relock it, or they are sitting with the whole Keychain unlocked. The command discussed is an easy way to pull passwords off of people's Macs. All you need is to wait for a few moments while they are distracted. This is a flaw. All passwords stored on the system should not be available for a passerby to examine without validation. Validation is only required if one is willing to unlock and relock the Keychain constantly, after every email check and site login.
- deleted 14y ago[deleted]
- tomwalsham 14y agoA nice visible reason why the Rails/Node/OSX FOSS community really need to stop doing the following sort of thing for their installations (seen most recently on yeoman.io, but common to get.pow.cx, npm...):: curl get.totallytrustworthyapp.io | bash The above examples are obviously legit, but encouraging this kind of lazy access to even local privileges from arbitrary remote scripts (and Yeoman even asks for sudo in a super-friendly way), is the modern equivalent of padlock.gif on your payment page - training poor security practices.
- blake8086 14y agoYou're still ultimately going to be running some code without reading all of it first, aren't you?
- muyuu 14y agoIn Firefox and Chrome you can see all web passwords in plain text. It used to be the same in Safari but apparently not anymore. And that's when they don't leave their webmail logged in, which a lot of people do and they lend you their computer like nothing happened. This is often a master key to somebody's privacy, usually more critical than the kind of stuff have in their keychain most often (WLAN passwords and the like). People around me are not the most security conscious, or they just know they can trust me. I guess there's also the cultural bias to allow people "check their email" and stuff like that. My keychain is always locked, I don't save sensitive web passwords in browsers, and I still don't let people use my computer unsupervised.
- kristopher 14y agoApple provides an easy way to lock your desktop when you go for coffee. To set it up: 1. Launch "Keychain Access". 2. Open Preferences from the "Keychain Access" menu 3. Check the option labeled "Show keychain status in menu bar" 4. (optional) While holding the cmd-key, click and drag the menu item over to the far right of the menu bar for easy access. Enjoy!