15 ms·
Best practices for user account, authorization and password management
- JoshTriplett 9y ago> Your service should instead store a cryptographically strong hash of the password that cannot be reversed — created with, for example, PBKDF2, SHA3, Scrypt, or Bcrypt. One of these things is not like the others, one of these things just doesn't belong Don't use SHA3 or any other fast hash for passwords. Use a password hash designed to stymie brute-forcing, like PBKDF2, scrypt, or bcrypt.
- iraklism 9y agoMillion guesses per second vs thousands. Really interesting how SHA3 made its way to this blog post.
- whatevaa 9y agoStill better than no hashing. Still a tough nut to crack if it's hashed plus salted with unique salt.
- oldcynic 9y agoUgh. It's supposed to be Best Practices, rather than better than nothing, and is ostensibly from Google. So should be limiting to the appropriate choices: bcrypt, scrypt, PBKDF2 or Argon2.
- user5994461 9y agoNot everyone can used the last hype algorithm, whether because of library support, regulations or technical constraints.
- mediumdeviation 9y agobcrypt is old enough to vote this year
- cyberfart 9y agostill can't drink in US though
- isostatic 9y agoSomething they acknowledge later with SMS being a bad idea, but may be the best option for a specific workflow.
- jabl 9y agoglibc crypt() uses sha512, IIRC (the thing that encrypts passwords in /etc/shadow). Iterated a number of times to make it suitably expensive. So perhaps not as good has the bespoke password hashing functions, but not a disaster waiting to happen either.
- JoshTriplett 9y agoSalting and iterating would make it more reasonable, but the article (a "best practices" document) didn't say to do that, or why.
- deleted 9y ago[deleted]
- 0x7f800000 9y ago#1 best practice for managing passwords is: don't try to implement password management yourself because you will get it wrong.
- Osiris 9y agoThat's exactly what I was thinking. Using OAuth logins from Google, Facebook, etc. saves a lot of pain.
- pavel_lishin 9y agoIt offloads that pain to the user. What if I no longer wish to have a Facebook account? What if I lose access to it?
- ams6110 9y agoOr what if I don't have one? Now I need to sign up for some social media platform that I don't want, just to use your service?
- zawerf 9y agoI had a lot of trouble implementing social logins the other day so it's not completely painless either. For example if you have multiple social logins, what do you do if the user forgets which account(e.g., google or facebook) they used? You could just let them login with any as long as the email matches. But then what if you have a social login type that doesn't require verified email? For example let's say you add an imgur login but the user doesn't have an already have an account there. Then an attacker can just create the imgur account with that unverified email and then use that to log into the same email on your site. There's also a bunch of edge cases with handling users who use different emails for different social accounts so you can't assume one-to-one correspondence between email address and users anymore. And there's a bunch of other issues with how to initialize a good default display name from these different social profiles. And also the issue with how to handle if they unlink all their social login methods. And how/who to send reset password. And so on and so forth. In the end this was all too hard and I gave up and only allowed logging in with google and google only. Which kind of sucks.
- marknadal 9y agoEven better best practices: Don't let the server be able to derive the password at all. Have fully P2P user accounts that use PBKDF2 to extend passwords into proofs that can client-side only decrypt public/private keypairs. For an example, see: https://github.com/amark/gun/wiki/auth https://github.com/amark/gun/wiki/auth
- jwilk 9y ago> If you must cap password length, only do so based on the maximum POST size allowable by your servers. This is commonly well above 1MB. Seriously. Yeah, no. If someone submits a megabyte-long password, it's not because they like it super strong; it's because they're trying to DoS the server. A sensible password length limit is probably a few kilobytes.
- taberiand 9y agoAnd for God's sake, ensure the length checks performed at login are the same ones used on account creation. More than a few times have I been stuck at login because my 20+ character auto- generated password was silently truncated to some arbitrary length between creation and login.
- davchana 9y agoIndia's version of 401k account, eNPS does that, will accept all passwords, but silently truncates at 14 char length, and when you try to login, throws error.
- notfed 9y agoBetter advice: have the client pre-hash the password before sending to the server.
- TheAceOfHearts 9y agoThird-party identity providers are bad for a number of reasons. My biggest issue is that none of the mentioned services make any guarantees against arbitrary account termination or lockdown. If the identity provider decides to lock you out, there's no recourse for the user. Google Accounts are notorious for this, making it nigh impossible to reach a human unless you have an engineering connection on the inside. This post is a blatant ad for Firebase Auth. Why isn't there any mention of competing services like Auth0 and okta? There's also lots of frameworks and libraries which handle everything for you with minimal effort. For example, you could setup something like Apache Shiro [0] as an independent service which you call out to from your app. I've seen a few different alternatives in this space, although I can't remember their names off the top of my head. They're usually written in Java, presumably because getting these features right is important for some enterprises. [0] http://shiro.apache.org/ http://shiro.apache.org/
- trevyn 9y agoWhat if you use third party auth, but keep your own account records, including email addresses? Then if you run into any issues with the third-party provider, you just "disable" the integration and do a normal email-based password reset flow.
- TheAceOfHearts 9y agoThat could be a viable path for some services. It really depends on the use-case, e.g. the kind of information being stored and how it's used. You could have the user register by providing an email and clicking a verification link, and then optionally allow em to link third-party services. Regular account access is allowed after authenticating through any available method, but administrative actions require going through the email flow. That way you reduce the risk from a compromised or malicious third-party. Of course, this would assume that email is a good identification authority, which isn't always the case.
- icebraining 9y agoYou could have the user register by providing an email and clicking a verification link, and then optionally allow em to link third-party services. You don't need that complex workflow; most third-party authentication services allow you to also request the user's email address during the initial process.
- deleted 9y ago[deleted]
- privacypoller 9y ago>> 8. Let your users delete their accounts Man, if I was drinking milk I would have shot it out my nose at that one. Google and every single social network are the last actors who make it easy (or even let you for-realize-ies) delete your association. They may let you remove access to the persona they store and monetize, but they certainly don't let you "easily delete your account". THis entire post is a giant crock.
- kyrra 9y ago(I work for Google, opinions are my own) https://support.google.com/accounts/answer/32046?hl=en https://support.google.com/accounts/answer/32046?hl=en Google does let you delete your account. But it can take a few weeks for all the data to be really deleted (there is a recovery period, then some lag to delete everything).
- TheAceOfHearts 9y agoDoesn't Google have tons of old backups in cold storage? Are those old database records also cleaned up?
- kyrra 9y agoI can't say what or whatnot Google does. Ask customer support on that. But do know that GDPR will require this for the EU. https://gdpr-info.eu/art-17-gdpr/ https://gdpr-info.eu/art-17-gdpr/
- aiiane 9y agoIt takes longer for data to get purged out of backups than it does for the live data stores, but Google does clean up backups for deleted account data.
- deleted 9y ago[deleted]
- kj65557 9y ago(also work for google) It is pretty easy to delete your account on many social networks. The following support deletion: * Google (all account data) * Facebook (all account data except messages that others have received) * Reddit * Instagram * Snapchat (requires you to "deactivate" for 30 days) One thing that is confusing is that many websites also have a "deactivate" feature. Some users may confuse the two and mistakenly think "deactivation" is the same as "deletion".
- ryan-c 9y agoMy (probably unpopular) opinion is that passwords should be randomly generated by the service, and not possible to change to a user-selected value. If you allow people to choose their own passwords, the vast majority will reuse them, and their account will eventually be compromised via credential stuffing. I recognize that this solution will, at least initially, infuriate people. Letting people opt in to federated auth if they prefer that (I hate services that require it) might make it more palatable.
- trevyn 9y agoFor services that generally "stay logged in", why have passwords at all? Just do "magic login link" emails, with some sort of 2FA if you're into that.
- zootm 9y agoIsn't the former what Mozilla Persona was trying to provide? A shame that was canned.
- onli 9y agoWe built a successor project under https://portier.github.io/ https://portier.github.io/. Alive and kicking :)
- ryan-c 9y agoI think "magic login links" are fine for most services. Doing 2FA with that is not feasible though, unless you want to argue that receiving the email counts as "something you know" or that "something you have plus something else you have" counts as 2FA.
- trevyn 9y agoIf you have your email protected with 2FA, I think you're covered -- "An unlocked device with an active session" is the thing you have. I think this is actually what's happened -- people now know not to leave unlocked devices unattended, so you basically do 2FA every time you unlock your device, so the device can now stay persistently logged into all services.
- torstenvl 9y agoUsernames should be fully case-insensitive. It's trivial to store usernames and email addresses in all lowercase and transform any input to lowercase before comparing. Case-insensitive comparison is not the same as convert-to-lowercase-and-compare. You should also normalize the input or you're going to set up issues where an account created on one device with one locale will be impossible to log into on another device with another locale.
- myroon5 9y agoInterested in this one. Could you provide a specific example?
- gbacon 9y agoSay a German user’s chosen name is spaß (“fun”). In all uppercase, that name is equivalent to SPASS or perhaps SPASZ and as of last year[0] SPAẞ. [0]: https://en.wikipedia.org/wiki/Capital_ẞ https://en.wikipedia.org/wiki/Capital_ẞ
- eCa 9y agoI have never seen ”ß” meaning ”sz” (or anything other than ”ss”), can you point me to a source?
- jwilk 9y agoFrom the Wikipedia article: Designs for an SZ ligature has been part of typesets from the 1910s until the 1950s, but in the opinion of Herrmann (2011), the long-standing alphabetic equivalence of ß with ss and the abolition of the optional capitalization of ß as SZ (abandoned in 1996⁽¹¹⁾) means that this is no longer a valid option that "Germans would want to use on a regular basis". ¹¹ until 1996, it was recommended to render ß as SS in allcaps except when there was ambiguity, in which case it should be rendered as SZ. The common example for such a case was IN MASZEN (in Maßen "in moderate amounts") vs. IN MASSEN (in Massen "in massive amounts"), where the difference between the spelling in ß vs. ss could actually reverse the conveyed meaning. Also, https://en.wikipedia.org/wiki/%C3%9F https://en.wikipedia.org/wiki/%C3%9F contains a concrete example: https://en.wikipedia.org/wiki/File:ABSCHUSZGERAET.jpg https://en.wikipedia.org/wiki/File:ABSCHUSZGERAET.jpg
- ricardonunez 9y agoValidate email addresses before people can use your service. I lost count how many people have created accounts using my email address just because I happen to own the Gmail for my name. Banks, health records, dating sites and even students emailing me their homework thinking I am their teacher.
- tedyoung 9y agoThis, 1,000 times this. I have gotten access to other folks' accounts who think they're using their email address, but they're actually using my email address. Car loans, job applications, doctor appointments, etc.
- vit05 9y agoThis happens to me and I'm already pissed off. It's a lot of emails from people who miss something in the address. Worse, these same people try several times to retrieve the password of an email that they do not have. Or put my email as a password recovery from their addresses. I get invoices from card accounts, personal emails, work emails. I've tried to search information in google forums to prevent them from putting my email as a recovery without the confirmation and apparently it is not possible. They create account in instagram, twitter, uber using my email and I need to go to the service to cancel the use of this address. Many times I have account with this address in certain service, but they sign up using a dot between the names and it ends up redirected to my email. I try to warn them but just ignore them. Since December I received this gigantic amount of requests to change my password, in none of them did I request it. https://i.imgur.com/Vh44YXd.png https://i.imgur.com/Vh44YXd.png
- fro0116 9y agoThat... sounds like a nighmare. I've always been slightly bitter about not ever having been able to get the canonical version of my first name or first name last name combination on email services due to having a rather common name, but now I'm kind of glad I wasn't able to after hearing what people in this thread have had to deal with. Out of curiosity, have you considered switching to a new email address? I've done so once in the past in the process of migrating from an @gmail address to an email address on a domain I own, and the process itself was every bit as slow and painful as anyone can imagine, but I feel the end result was totally worth it because now I can freely switch between providers without worrying about going through that process ever again. Just mentioning this because it seems like switching to an email on a custom domain would largely take care of the issue of random people mistakenly using your email as well.
- cakoose 9y agoThis is surprisingly lower quality than what you'd expect from Google. > Your service should instead store a cryptographically strong hash of the password that cannot be reversed — created with, for example, PBKDF2, SHA3, Scrypt, or Bcrypt. Not distinguishing between plain cryptographic hashing and password hashing is a newbie mistake. > With that in mind, you should allow your users to use literally any characters they wish in their password. You can't just say this without making sure people understand Unicode normalization, or they're going to get bitten later. I realize this post is from GCP evangelism, but it's still the "Google" brand, which has a good reputation for security so a lot of people are going to trust it. I wonder if an internal product security person even reviewed it.
- fuck_google 9y agoGoogle - expect the unexpected.
- Matt3o12_ 9y agoCan you point me to good resources to learn more about Unicode normalization especially for passwords? What are the gotchas? One the one hand, when users are allowed to enter any character, they often have difficulties to log in when they are aboard and not use their own devices. Though, I don't know if every Russian (for instance) would be able to enter a "English" password.
- lrem 9y agoI believe, as a matter of necessity, every PC out there will allow any user to enter ASCII, even if it's not within their contry language's alphabet.
- ademarre 9y agohttps://tools.ietf.org/html/rfc8265 https://tools.ietf.org/html/rfc8265
- drdaeman 9y ago> Though, I don't know if every Russian (for instance) would be able to enter a "English" password. I believe in every country with non-Latin alphabet users have two keyboard layouts: local (e.g. Russian) and English/Latin. All major OSes (desktop, tablet or mobile) have install-time defaults like this, and I never ever saw any divergence from this rule, except for removing native layout if it's deemed unnecessary and going English-only, or configuring system to use some third language (e.g. a foreigner setting up a device purchased abroad, changing the defaults). I mean, I never saw anyone in their sane mind removing English layout and keeping only the local. It is virtually impossible to use computers without having to type in some Latin characters on some occasions, like typing URLs or email addresses. Therefore, I think you may reasonable safely assume capability to enter basic Latin. However, you should also consider that user may forget to switch the keyboard layout (happens all the time), so if you want to do some password transformations like case-insensitive password matching (due to Caps Lock), and you have significant foreign user base, you may also want to consider common keyboard layouts issues (e.g. "hunter2" <-> "ргтеук2" for QWERTY <-> Russian).
- CM30 9y agoOkay, I'm probably going to get a fair bit of heat for saying this, but am I the only one who's never been a huge fan of letting users delete all content associated with their account at will? I mean, in the olden days of forum software, this sort of thing was removed as a feature for a reason. Because it meant that if left uncontrolled, people could basically destroy discussions and make the site difficult to use by removing vital information from the middle of a conversation or making it hard to track whatever's going on. See for example many old Reddit topics, where you've got a long string of names saying 'deleted' and comments referencing some script that 'removes all posts to protect the user's privacy' or what not. That's why my ideal solution has always been to basically say 'by signing up with this service, you grant us an unrevocable, unlimited right to use your posts for the purposes of the community' with a nice 30 minute or so editing window set for content. Don't like that? Well that's life I think. You can't take back emails or phone calls and you can't ask people to take your name or information out of a book or magazine once it's been available for years. Still, maybe I'm old fashioned now.
- goblins 9y agoTell that to the EU.
- Kequc 9y agoOne of the primary reasons I don't like posting here or on services like you describe is because I cannot delete anything. Maybe you've enough users who don't care about that but it should be taken into consideration that many people will not participate. You'd be therefore trading direct communication for archived communication and I'm not sure that's more valuable.
- aiiane 9y agoThere's a significantly higher barrier to having your personal information show up in a book or magazine (eg editors). People make stupid mistakes on social websites on the time.
- kuschku 9y agoI suggest you read about the new European General Data Privacy Regulation, which comes into force in May 2018, and requires you to allow users to (a) export and (b) delete all personal data they gave you, including messages, posts, etc. Violation will be punished with a fine of up to 20 Million EUR or 4% your global revenue, whichever is higher. This law will apply to all sites that have EU customers, no matter where the site is located, and will be enforced globally (through banks assisting with account freezes, etc).
- mindcrime 9y agoThis is timely as I am literally just getting into working on the account management / login / registration stuff for a new app tonight. Most of this stuff isn't really new, but it's good to have a reminder, and/or validation of certain things. We're not (currently) doing 3rd party providers like Google / Twitter / Facebook, but since we have (well, will have) multiple independent apps out there, we have a CAS[1] server set up for SSO and all our apps use that for authentication. This current app is a little more complicated to deal with, since it's basically an "app for provisioning apps". So we have "login to the main site" level login, and then login / authorization for the stuff that gets provisioned. We also want to support things like "invite a user to join via email", etc. Still working on how exactly the user experience will work on some of these scenarios. [1]:https://github.com/apereo/cas https://github.com/apereo/cas
- matt_wulfeck 9y agoThis article is basically one giant ad for using google sign in for your website... and for good reason! They know what they’re doing. I’m delighted when I see that I can create an account using Google SSO because I’m so much more confident with them.
- EGreg 9y agoThis is good advice. However in 2018 you can go a lot further. Our company wrote up this guide: https://qbix.com/blog/index.php/2018/01/modern-security-practices-for-web-developers/ https://qbix.com/blog/index.php/2018/01/modern-security-prac...
- cjsawyer 9y agoLeave it as Hunter2 and call it a day
- secabeen 9y ago> Do not store plaintext passwords under any circumstances. I really wish the original EAP-TLS specification had had some support for passing passwords across the TLS session. Certificates are great, but so few places provided them, and everyone who wants to easily support Windows 7 machines on the WPA2-Enterprise system has to store plaintext passwords on the server to support MSCHAP-V2. EAP-TTLS finally did solve that problem, but with Windows 8. When Windows 7 finally dies, one of the first things I'm going to do is discard the plaintext passwords in my authentication databases.
- mygo 9y agoYou store plaintext passwords? Interesting... where do you work? What’s your tech stack? Oh and what’s your name? ...
- interfixus 9y ago> Third-party identity providers enable you to rely on a trusted external service to authenticate a user's identity. Google, Facebook and Twitter are commonly used providers The highly trusted Google and Facebook indeed. Nothing like a fresh oxymoron to start my Sunday.
- pgodzin 9y ago> Allow users to change their username Does Google allow me to change the username of my elementary-school aged gmail account?
- zerr 9y agoDo not tell them this, they will completely disable your account.
- balladeer 9y agoThey also say this: > Don't impose unreasonable rules for usernames On Google+ the selection of vanity URL is such a master stroke of tragedy that it hurts to think whether the restrictions are idiotic or just incompetent. They already have decided the first part of your username for you: <base_url>/FirstnameLastname........ Yes, You only get to choose the last part of your username - the first part is decided. Even though "Firstname, or "Lastname", or "FirstnameLastname", or anything else that you want to choose is available, you can't choose them - unless you are famous enough or possibly you know someone at Google. The latter, I believe, is also very useful if you happen to lose access to your Google account. After trying twice I just deleted Google+ from my Google a/c.
- chx 9y agoHere's my advice: do not use passwords. Just don't. If someone wants to log in, mail them a one time link. And make the session long enough this doesn't happen often -- when was the last time you needed to log into HN or Github? We also AES encrypt the emails with the key stored on a network share. It doesn't add a lot of complexity and if an attacker gets hold of the contents of the database, they still don't have this piece of PII. It's by no means a big hurdle against any serious attack but it's nice to have.
- reallymental 9y agoAnd how do I log into my email account to access this one time link? Edit: Even if it's an account held on a private server, there must be a password, must there not?
- vertex-four 9y agoTheoretically you could use x.509 certs and a key stored on a smartcard type device, but sure. Point is, this advice is probably aimed at developers who aren't working on email systems.
- newscracker 9y agoProvisioning and maintaining the certificates/keys across even a small user base is a huge pain compared to letting users choose their own passwords.
- vertex-four 9y agoHence theoretically. :)
- newscracker 9y agoEdit: This is a decent enough solution, though it comes with its own pitfalls. How exactly are you sure that the email is encrypted and is read only by the intended receiver and not by anyone else? This is too simplistic as a solution. Things like what to do if a user clicks on the same link more than once also have to be considered (is it really the intended user who clicked it or a malicious actor that the user is not aware of?).
- nnq 9y ago> 4. Allow multiple identities to link to a single user account Hallelujah! Finally someone like Google recommends this, so I'm no longer going to be called for crazily overengineering it every time I suggest this... Pretty please, read points 3 and 4 from this guide and take them into consideration if you're designing any king of reusable auth-library thinggy or a framework. (If you'd also also add entity-role-based permissions so I can say "this account has role X with respect to resource Y, which grants him permissions A, B, C etc." then finally you have the minimal required imho auth/indent/perms system for your framework and I will not have to rip it off and replace it with a custom one every time, or add zillion of patches on top of it...).
- ubernostrum 9y agoThe correct pattern for this has been known for a very long time: http://habitatchronicles.com/2008/10/the-tripartite-identity-pattern/ http://habitatchronicles.com/2008/10/the-tripartite-identity...
- stedaniels 9y agoSo has anyone got a guide on implementing the relevent portions of these best practices in ADFS?
- spydum 9y agoCheck out Azure AD. Most of the best practices are implemented there.
- mike_hearn 9y agoI used to work on Google's account system and wrote up a set of suggestions for how to implement user accounts on your website here: https://blog.plan99.net/building-account-systems-f790bf5fdbe0 https://blog.plan99.net/building-account-systems-f790bf5fdbe... The advice overlaps in various areas, but is different in a few. Might be useful as another take and to see what's the same and what's different.
- spydum 9y agoGreat post Mike! Just wish there was a solid solution for identity providers in the enterprise space (gsuite and activeAD exist, but pretty rare). Instead every company ends up building their own IDP and making all these same mistakes. The difference is they aren't often quite as targeted for abuse (tho depends on the business).
- featherverse 9y ago1. Hash passwords 2. Allow third party identi-... WAIT, STOP. WHAT?! Allowing third party authentication in your software is not a "best practice". The blog is some corporate advertising bullshit that Google is trying to shove down your throats under the guise of a public service thing. Jesus Christ why is evil tolerated? Entertainment value? "Third-party identity providers enable you to rely on a trusted external service to authenticate a user's identity." Anyone who trusts Google or Twitter or Facebook, the three listed, is an idiot and doesn't know anything about internet security and has no place writing authentication schemes or working at that level of I.T. full disclosure, I allow social logins on my personal blog. Because it's just a blog and who cares. If it were a sensitive system for example, a bank or a credit agency, then under no circumstances would a third party authorization be allowed.
- sethammons 9y ago> SMS 2FA auth has been deprecated by NIST (https://pages.nist.gov/800-63-3/sp800-63b.html https://pages.nist.gov/800-63-3/sp800-63b.html) due to multiple weaknesses, however, it may be the most secure option your users will accept for what they consider a trivial service. I skimmed through the NIST document and couldn't find that claim. > [5.1.3.1 allows if] sent from the verifier to the out-of-band device via the PSTN (SMS or voice). Maybe it is interpreting this part from the same section? > the device SHOULD NOT display the authentication secret while it is locked by the owner So it seems to me that SMS is not deprecated but open to issues if the SMS shows the secret. I looked a little deeper in the doc. Section 5.2.10 on Restricted Authenticators lays out that devices could become restricted as times change, but I couldn't find where the doc actually says 2FA over SMS is now restricted. The post claims that users may allow SMS for trivial services, but does not call out what that means. I don't use more than a password manager for trivial services (forums and the like), and I use 2FA over SMS for things that might have financial details (if 2FA is an option). The rest of the article makes sense, but I'm having trouble with this one point. Did I miss something in the NIST document? And if 2FA over SMS is out, as a website with billing, should one look at using an authenticator like Duo? The author says to just auth via Google et al, but that feels like kicking the can down the road hoping they or Twitter have something better than 2FA over SMS.
- bowyakka 9y agoIt was in older versions from 2016 [Out of band verification] using SMS is deprecated, and will no longer be allowed in future releases of this guidance
- sethammons 9y agoah, thanks!
- raarts 9y agoUsing Google and Facebook for your user's login is easy and safe. It's when programmers create there own login process where true problems arise. Does anybody have any data on the percentage of users that refrain from using Google/Facebook and always create email accounts?