TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to Safely Store Your Users' Passwords in 2016

479 点作者 antitamper超过 9 年前

33 条评论

jordonias超过 9 年前
I called my bank the other day and they asked over the phone for my password. This isn't a bank I often use, I only currently have a loan through them so I've never used the login on the website. I said I don't remember setting a password. They gave me a hint about the characters in the password and I was able to remember the password based on their hint. I verbally said the password character by character and they confirmed it. This is an example of how to not handle passwords in 2016.
评论 #11122135 未加载
评论 #11120270 未加载
评论 #11123583 未加载
评论 #11120208 未加载
评论 #11124952 未加载
评论 #11126803 未加载
评论 #11121250 未加载
评论 #11120981 未加载
评论 #11121249 未加载
jtwebman超过 9 年前
Bad idea to use bcrypt.hashSync in Node.js. I hate that so many tutorials use that one instead of the correct bcrypt.hash with a callback. This is Node.js for that 200 ms where you are hashing that password nothing else runs, no requests, everything stops. Here is the correct way to use bcrypt in Node.js:<p>bcrypt.genSalt(10, function(err, salt) {<p><pre><code> if (err) return; &#x2F;&#x2F;handle error bcrypt.hash(clearPassword, salt, function(err, hash) { if (err) return; &#x2F;&#x2F;handle error &#x2F;&#x2F; Store hash in your password DB. }); </code></pre> });
评论 #11120380 未加载
评论 #11122965 未加载
评论 #11122920 未加载
jayeshsalvi超过 9 年前
By not storing them <a href="https:&#x2F;&#x2F;medium.com&#x2F;the-story&#x2F;signing-in-to-medium-by-email-aacc21134fcd#.fkttu9kdh" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;the-story&#x2F;signing-in-to-medium-by-email-a...</a>
评论 #11120890 未加载
评论 #11121084 未加载
评论 #11120811 未加载
评论 #11160200 未加载
评论 #11129473 未加载
评论 #11120874 未加载
VincentEvans超过 9 年前
Serious question: What about using a Public&#x2F;Private key encryption to store the password?<p>- Private key is stored in a secure place. Offline for all i care; printed on a piece of paper; memorized and swallowed.<p>- When user creates the account - password is padded with salt, then a public key is used to encrypt it. The resulting encrypted form is stored, along with the salt.<p>- When user attempts to authenticate - the password that is provided is padded with the stored salt, encrypted with the public key and compared to the stored password.<p>Private key is never used when comparing passwords. Never available to the system doing authentication, etc.<p>The only purpose of using a reversible encryption - is to be able to switch to a different authentication provider completely transparently to the user.<p>I&#x27;ve implemented this functionality considering that we may need to switch over to active directory (or some other directory) in place of storing passwords in the database - but never used it, fearful that i would be committing some cardinal crime against proper security practices<p>Thoughts?
评论 #11122729 未加载
评论 #11121882 未加载
评论 #11122875 未加载
评论 #11125946 未加载
评论 #11123797 未加载
Freaky超过 9 年前
&gt; base64_encode(hash(&#x27;sha384&#x27;, $password, true))<p>&gt; ...<p>&gt; The above construction may invite theoretical concerns about entropy reduction (i.e. 72 characters of raw binary without any NUL bytes comes out to about 573 bits of possible entropy, but a SHA-384 hash outputs are clearly limited to 384 bits).<p>Given BCrypt hashes are a mere 184 bits, I don&#x27;t see how this is a meaningful concern even in principle. If you&#x27;re brute-forcing search spaces this big you&#x27;re no longer looking to recover a password, but find a collision.
评论 #11119658 未加载
AdmiralAsshat超过 9 年前
I had no idea that PBKDF2 had fallen so much in recent years. I still remember the 1Password team extolling its virtues five years ago:<p><a href="https:&#x2F;&#x2F;blog.agilebits.com&#x2F;2011&#x2F;05&#x2F;05&#x2F;defending-against-crackers-peanut-butter-keeps-dogs-friendly-too&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.agilebits.com&#x2F;2011&#x2F;05&#x2F;05&#x2F;defending-against-crac...</a>
评论 #11120528 未加载
评论 #11119714 未加载
rcconf超过 9 年前
If you&#x27;re using node.js and you use these hashing methods, your entire server is going to pause for 0.5 seconds on a login because it runs on a single thread. Goodbye to all of your server performance.<p>You can create a worker system, or use a child process to solve this problem, but most of these articles never mention it
评论 #11119267 未加载
评论 #11119466 未加载
评论 #11122338 未加载
评论 #11120715 未加载
评论 #11119842 未加载
评论 #11119457 未加载
评论 #11119548 未加载
hellofunk超过 9 年前
It would be great if, in 2020, or sooner, but probably later, the answer is &quot;don&#x27;t use passwords any more. They are deprecated components of society.&quot;
评论 #11120983 未加载
评论 #11119999 未加载
josefdlange超过 9 年前
Anyone have a good explanation of why, in the Python example, they recommend `hmac.compare_digest` instead of `==` for comparison?<p>Is there something obvious I&#x27;m missing here?
评论 #11119177 未加载
评论 #11119207 未加载
评论 #11119166 未加载
oliwarner超过 9 年前
Disappointed that the first solution isn&#x27;t: Let somebody else do it.<p>I know this doesn&#x27;t apply to banking, etc but 99% of the websites that &quot;require&quot; me to create an account and log in don&#x27;t need to store primary credentials for me. Please pick a secure implementation of oAuth2 and let people store their credentials wherever the hell they want to.<p>I&#x27;m bored of getting hits from &quot;Have I been pwned?&quot;
评论 #11125873 未加载
TorKlingberg超过 9 年前
For some reason the article completely fails to link to libsodium: <a href="https:&#x2F;&#x2F;download.libsodium.org&#x2F;doc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;download.libsodium.org&#x2F;doc&#x2F;</a>
评论 #11119690 未加载
damon_c超过 9 年前
I have always been impressed by the way django does it.<p><a href="https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;1.9&#x2F;topics&#x2F;auth&#x2F;passwords&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;1.9&#x2F;topics&#x2F;auth&#x2F;passwords&#x2F;</a>
pbreit超过 9 年前
Assuming this is legit (seems like it), mega bonus points for walking through examples on the various platforms&#x2F;languages.
sinatra超过 9 年前
From previous discussions about this topic, I had noted down the following best practices:<p>Passwords should be scrypt&#x27;ed on client, and then, the server should generate a SHA256 hash of the scrypt&#x27;ed hash and store that in DB.<p>- Running CPU &amp; memory heavy scrypt hashing on the client side will allow us to use bigger hashing work-loads.<p>- EDIT: Removing the MITM point, because as many said, that&#x27;s the job of TLS anyway.<p>- External brute force attackers will have to take the burden of heavy hashing. No DOSing through scrypt.<p>- Storing SHA256 hash instead of scrypt hash on DB means even if DB is stolen, attackers can&#x27;t use stolen scrypt hashes to authenticate any client.<p>I would love to get others&#x27; feedback on this. EDIT: Found the reference: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9305504" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9305504</a>
评论 #11120973 未加载
评论 #11120952 未加载
评论 #11120994 未加载
评论 #11120999 未加载
评论 #11120939 未加载
Justsignedup超过 9 年前
Wish there was a site where it lists algorithms and gives a table, and an ability to compare it to x years ago:<p>algorith | fairly safe difficulty (all variables) | very safe difficulty without incurring too much performance cost.<p>pbkdf + sha1 | completely unsafe | completely unsafe<p>pbkdf + sha2 | 100000 | ...<p>pbkdf + sha256<p>bcrypt<p>scrypt<p>argon2
评论 #11120576 未加载
sarciszewski超过 9 年前
I&#x27;m part of the Paragon Initiative Enterprises team and have access to edit the blog. If you have any questions (AMA) or would like to suggest any additions, please let me know.
评论 #11120596 未加载
latenightcoding超过 9 年前
Perl programmers should try this module: Crypt::ScryptKDF I have been using it for a while now
评论 #11123024 未加载
cm2187超过 9 年前
What I find frustrating is the lack of availability of most of these algorithms for the most common platforms (.net, php, java). The author recommendation seems to be driven by availability, not the algorithms own merits.
评论 #11125566 未加载
评论 #11124415 未加载
astockwell超过 9 年前
I believe the Ruby example is incorrect: When checking a password&#x27;s validity, you must use a constant-time comparison or else you are exposing a vulnerability to side-channel timing attacks.<p>There is an open issue in Coda Hale&#x27;s bcrypt repo about this: <a href="https:&#x2F;&#x2F;github.com&#x2F;codahale&#x2F;bcrypt-ruby&#x2F;pull&#x2F;119" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;codahale&#x2F;bcrypt-ruby&#x2F;pull&#x2F;119</a><p>My stance on posting &quot;best practice&quot; articles is: you must follow <i>all</i> best practices in them.<p>&lt;Edited for clarity&gt;
评论 #11122783 未加载
评论 #11122362 未加载
movedx超过 9 年前
Hashicorp&#x27;s Vault (vaultproject.io) is also an excellent way of controlling access to secrets and back ends, such as PostgreSQL.<p>It&#x27;s worth spending the time to learn, implement, and integrate into the security best practices you should already be deploying.
carlesfe超过 9 年前
Here&#x27;s yesterday&#x27;s discussion for the exact same post (maybe the duplicate search failed this time?)<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11108481" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11108481</a>
jimktrains2超过 9 年前
Or, we could move to not storing passwords at all, viz client certs and SRP.
评论 #11119272 未加载
firelink超过 9 年前
I kind of don&#x27;t like this article. I think we should be teaching people best practice for securing and storing a password, not simply giving them a library.
dogweather超过 9 年前
I believe that the safest way is not to save them. Instead, outsource this to a few select OAuth providers which you and your customers are willing to trust.
评论 #11123563 未加载
评论 #11124321 未加载
评论 #11123440 未加载
balls187超过 9 年前
&quot;How to Safely Store a Password in 2016&quot;<p>Don&#x27;t. Unless it&#x27;s 100% absolutely necessary.<p>If you must, continue reading on.
评论 #11120916 未加载
评论 #11120014 未加载
xjlin0超过 9 年前
Ruby&#x27;s argon2 gem is pretty good!
intrasight超过 9 年前
Storing passwords is like storing credit card numbers - just don&#x27;t do it
giancarlostoro超过 9 年前
I&#x27;m curious if any D developers care to share their approach to this?
pratnala超过 9 年前
Does Argon2 have an official website and repo or is it just the PHC repo?
评论 #11119678 未加载
privong超过 9 年前
For anyone who reads the comments before clicking the article, the subject is storing your users&#x27; passwords, not managing your passwords for a variety of services. I had interpreted it as the latter. A better title might be &quot;How to Safely Store Your Users&#x27; Passwords in 2016&quot;.<p>(Title is currently: &quot;How to Safely Store a Password in 2016&quot;)
评论 #11119733 未加载
评论 #11119506 未加载
评论 #11120068 未加载
serge2k超过 9 年前
&gt; PBKDF2 (nearly everyone except FIPS agrees this is the worst of the acceptable options)<p>is that true?
评论 #11120552 未加载
PixelB超过 9 年前
I use an ultra secure method for my passwords, it is 100% unhackable.<p>Proprietary Analog Password Encryption Routines.
评论 #11122905 未加载
xs超过 9 年前
Lame title. Story talks about storing password hashes and not passwords. I&#x27;m still looking for a solution to storing actual user passwords. Scenario: All laptops in the company have a unique local administrator password. How do I manage this effectively as a domain admin?
评论 #11123610 未加载