Cybersecurity got ever more attention

Search for a command to run...

No comments yet. Be the first to comment.
Automating the boring stuff in job applications, while keeping the final decision in your hands.

Automating the boring stuffs ...

Managing S3 Case Sensitivity in Python Workflows

🌩️ Cloud computing has revolutionized how applications are developed and deployed, providing a more flexible and scalable environment for running workloads. AWS offers several services for event-driven computing, including Amazon CloudWatch Events a...

Introduction📝 Looking to streamline your complex workflows and keep everything on track? Look no further than state machines - a powerful tool for precision and ease in process management. 💪🏼 And when it comes to implementing state machines, AWS S...


At the top of the list of security issues are passwords. Many people believe it is the weakest link in internet security (some believe it is permanently broken).
From established multinational firms to early stage startups, everybody has an obligation to store user credentials securely. Here at Rangle, we wanted to show our recommendations for storing user passwords and improving security of your applications in 2017. This tutorial will cover the user experience from the front end, all the way to the database. Let’s get started.
It all begins when you ask your user to create an account by setting a username and password. This is where user experience will need to play nicely with proper security measures. United States National Institute for Standards and Technology (NIST) is currently finalizing their recommendations for password management. Some of these include:
P@ssword1 is NOT a good password). Instead, encourage people to set long passwords with high entropy (upper case letters, lower case letters, digits, special characters).Once the user has registered, there are two things to keep in mind:
Now that the user has entered a good password, they will submit the form and trust you to take care of their credentials. In the second step, you are transmitting the form (account sign up) data in a POST body to your server. You do it this way for a few reasons:
POST requests are never cached POST request will not remain in the browser history No restriction on data length
Most importantly, use HTTPS so that this data will be encrypted and cannot be attacked by someone who is observing your network traffic. HTTPS is the regular HTTP protocol with SSL/TLS encryption which means that only the server can read what you send it, and only you can read what the server sends back. To use HTTPS, simply purchase an SSL certificate and follow the steps in this article.
Now that we have received the username and password to our server it is time to do a few things. Before we get started though, always remember to never store passwords in plaintext. Instead, you will want to use some of these popular npm packages to hash the password: argon2, scrypt, or bcrypt. We prefer bcrypt for three reasons: 1. bcrypt is 15 years old and has been vetted by the crypto community. Although argon2 won last year’s password hashing competition, it is still fairly new and we would like to see it have a longer lifespan in the crypto community. 2. scrypt is 7 years old and also a good choice, but bcrypt is a bit easier to implement in a node.js server with simpler documentation as you will see below in the example. 3. The bcrypt npm package is better over other bcrypt implementations available on npm since it is native, highly popular, and vetted by the community without trying to reinvent the wheel.
Now you might be asking yourself, why not just use a hashing function like SHA256, add a salt (randomly generated bytes to place in front of the password) for each user, and store those in a database? The problem with computing power increasing is that attackers can now use GPUs to try out passwords at over 100 million per second and see if they get a hit. That’s why you want to use hash functions that were specifically designed to be slow. Although it is fast enough so the user won’t notice (about 100ms), it is long enough to make it infeasible for an attacker to try out a long list of passwords. bcrypt allows you to add a saltRound (10 is the recommended value) which iterates 2^10, or 1024 times over the password in a process called key stretching. Finally, bcrypt implementation is also safe from timing attacks. Here is a simple overview of how to use bcrypt for password management. (you can check out their repo for more detail):
/*
* You can copy and run the code below to play around with bcrypt
* However this is for demonstration purposes only. Use these concepts
* to adapt to your own project needs.
*/</span><span id="cd40" class="de km ix bo ke b fp kq kr ks kt ku ko r kp">import bcrypt from'bcrypt'
const saltRounds = 10 // increase this if you want more iterations
const userPassword = 'supersecretpassword'
const randomPassword = 'fakepassword'</span><span id="1dbd" class="de km ix bo ke b fp kq kr ks kt ku ko r kp">const storeUserPassword = (password, salt) =>
bcrypt.hash(password, salt).then(storeHashInDatabase)</span><span id="9ba5" class="de km ix bo ke b fp kq kr ks kt ku ko r kp">const storeHashInDatabase = (hash) => {
// Store the hash in your password DB
return hash // For now we are returning the hash for testing at the bottom
}</span><span id="96c9" class="de km ix bo ke b fp kq kr ks kt ku ko r kp">// Returns true if user password is correct, returns false otherwise
const checkUserPassword = (enteredPassword, storedPasswordHash) =>
bcrypt.compare(enteredPassword, storedPasswordHash)</span> <span id="8d35" class="de km ix bo ke b fp kq kr ks kt ku ko r kp">// This is for demonstration purposes only.
storeUserPassword(userPassword, saltRounds)
.then(hash =>
// change param userPassword to randomPassword to get false
checkUserPassword(userPassword, hash)
)
.then(console.log)
.catch(console.error)</span>
That’s it! You can now rest assured that you have stored the user password securely. The interesting thing with security is that it is always a cat and mouse game. Security advice changes with the time as new exploits are discovered and computing power increases. New attacks will be discovered but so will new solutions. Remember, the best security for your application means constantly keeping up with vulnerabilities, software updates, and new tools. For now, you can breathe easy…
Don't forget to Like , share and drop your reviews!
I'm happy to connect with you on Twitter .