5 ms·
I think this says more about node.js than it does about the proper way to secure a password.
by lukev 11y ago
I think this says more about node.js than it does about the proper way to secure a password.
- StavrosK 11y agoIt definitely does, and I think that's the GP's point.
- ARussell 11y agoWasn't Node's big draw early on (aside from the fact that it's JavaScript) the fact that everything is supposed to be asynchronous? I'm actually surprised this is a problem.
- mobiuscog 11y agoasynchronous doesn't magically make CPU-intensive tasks faster.
- kornish 11y agoCorrect, but it sure does stop your entire single-threaded process from blocking to the detriment of all other requests.
- corobo 11y agoIt does mean other tasks (e.g. serving pages to visitors) can still be run at the same time as the CPU-intensive task though, like most languages do when it comes to hashing passwords and logging people in
- sotojuan 11y agoEverything is asynchronous but the linked article uses the synchronous versions of the functions for some reason... async versions exist and are recommended[1] [1] https://github.com/ncb000gt/node.bcrypt.js#async-recommended https://github.com/ncb000gt/node.bcrypt.js#async-recommended
- zwily 11y agoDo the async methods actually execute on a thread pool though? Or do they use enough async methods internally to periodically release the main thread enough to keep it responsive? From a quick glance at the source, the answer to the first is no.
- herbst 11y agoWouldnt this happen with pretty much anything that is not threaded by default? Clearly with PHP you give a fuck, but i assume its not different with Ruby, Python, Go, ASP or anything else. You just usually use them threaded.
- Joeri 11y agoPHP is usually deployed in a FastCGI multiprocess setup, so the server will keep handling requests on the other processes while the hashing process is blocked. I wonder whether threading really saves you, given that there are only so many cores in a system and password hashing is CPU heavy. Naively it seems a DoS would involve sending as many parallel requests as there are cores, which is not a lot and can easily be done from a single machine.
- sarciszewski 11y agoThe blog post that HN is reading is served by PHP-FPM + nginx, without any extra special features to handle the load of an unexpected "oh hey we made it to the front page of HN". It's also hosted on a relatively cheap VPS.
- seanp2k2 11y agoConsidering the other article from HN today about Stack Overflow being able to handle their top-100 global Alexa rank traffic with one physical web front end, I'm impressed but not that impressed. PHP has been popular for a long time and lots of smart people have figured out how to make it pretty quick. For things like blog posts, I'm sad that Movable Type fell out of favor. The pattern of using dynamic server pages to edit blog posts and generate static files for your viewers just makes so much sense to me. Then again, these days we can host our single-page JS front-ends on S3 + CloudFront and hook them up to API gateway and Lambda / Beanstalk talking to RDS and "not have any servers" :)
- herbst 11y agoI know thats what i ment with usually you give a fuck, i dont know any way you could run PHP single threaded on a server (i mean there sure is). But its something common you learn when you programm in the other languages i mentioned. I dont think it could get a real issue in a real environment, except someone really wants to fuck with you. But the some fail2ban on to fast requests should fix this easily as the hashes dont actually take that long.
- EGreg 11y agoIt says both. The hashing is computationally expensive and Node runs in a single process (if we ignore workers). They could have made an implementation that yields and resumes after several ms. or you can spawn a worker and send it jobs.