create account

Digital authentication: how passwords are safely stored online by lucabarbera

View this thread on: hive.blogpeakd.comecency.com
· @lucabarbera · (edited)
$6.69
Digital authentication: how passwords are safely stored online
![image.png](https://files.peakd.com/file/peakd-hive/lucabarbera/bGU857sF-image.png)


Modern online services (websites and platforms) do not allow multiple unrestricted login attempts as that has been identified as a vulnerability: only a small number of wrong passwords (typically 3 to 5) can be tried before the account is locked down for some time, making direct brute force attacks unfeasible. This, however, does not protect a platform against being compromised. When hackers break into a system and successfully extract the password database, entire blocks of credentials (username, password, and possibly other sensitive information) are exfiltrated: that is a data breach.

###### Hashing and rainbows
[Data breaches are frequent](https://en.wikipedia.org/wiki/List_of_data_breaches), and often have catastrophic proportions. To protect users' credentials from a breach it is standard practice not to store passwords in cleartext, and even better not to store passwords at all. Instead, when a username/password pair is created or updated in a system, the sensitive data is passed through a *hash* - a one-way function where data is mapped to a fixed-length value. Under the assumption that the chosen hash function is robust against collision (that is, its output is unique for each unique input) the platform database will store just the hash, which does not contain any information about the original password except matching it when the password is passed through the hash function.

Once an attacker has a copy of the password database, it can attempt to crack it by attacking it with a dictionary of known passwords, and a series of functions that make every possible attempt at password permutation from random strings, which is commonly known as brute-force attack; however, as passwords are hashed, both attacks require the real-time computation of the hash. Since a good password hash function is slow (which is a very desirable property as the cost of a slow function is negligible during normal authentication operations) this would take too long.

To circumvent this problem, the attacker may then rely on *rainbow tables*: these are very large, pre-computed tables for caching the output of cryptographic hash functions. Rainbow tables are fast because they are removing the need for the attacker to execute any hash calculation; the trade-off is that these tables have a huge size (up to tens of Gigabytes), but that has become less of a problem as storage space has been commoditized and larger media availability is now mainstream.
With the usage of rainbow tables, an attacker can quickly perform a reverse lookup from the hashed values and obtain the corresponding password. This is possible because the nature of the transfer function guarantees that, for the same function, a password will always result in the same hash.

###### Salt and pepper
Rainbow table attacks can be thwarted by the use of a *salt*: a fixed-length cryptographically-strong random value that is used as an additional input to the hash functions, concatenated to the beginning or the end of a password. As each password has its salt, this causes the function to create unique hashes for every input, even if the input was not unique; in other words, thanks to the salt, each password hash will be different even if the passwords that generated it were the same. 
This technique prevents a rainbow table attack as the hash dictionary would have to be recomputed for each password, making precomputation infeasible as long as each password has a unique salt.

Salts are stored in cleartext along with hashes and username in a server database. At login time the system will look up the username, append the salt to the provided password, calculate the hash and authenticate the user if the result is matching the stored hash. 

According to the [OWASP guidelines](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#Use_a_cryptographically_strong_credential-specific_salt), the robustness of this solution depends on two factors:
- *salts must be unique per each stored credential*
Using the same salt for all passwords would add no security at all, as two identical passwords with the same salt will still result in the same hash, effectively negating the purpose of salting. Similarly, user-based salts would be insecure, because if the user was recycling the same password after performing a password update, the resulting hash would be the same.

- *salts must be cryptographically-strong 32-byte or 64-byte random data*
This is necessary as a longer salt is effectively increasing the computational complexity of attacking passwords, while at the same time increasing the space required to store rainbow tables.

It is interesting to observe that this schema does not rely on hiding, encrypting, or obfuscating the salt, which is stored in cleartext. That is because the purpose of salting is to prevent an attacker from cracking the passwords in general and make attempts such as rainbow tables ineffective. Salts will be exfiltrated as well in case of data breach, and knowledge of salts does not weaken the robustness of hashes.

For this reason, an additional layer of protection is usually implemented, called *pepper*.
The pepper is similar to the salt but it has two key differences:
- the pepper is shared between all stored passwords, rather than being unique like a salt
- the pepper is not stored in the database, unlike the salts.

While salts have no requirement for secrecy and are commonly stored alongside hashes, the pepper will be stored separately to keep it secure in case of a database breach. 
According to the OWASP guidelines, the pepper should be randomly generated and at least 32 characters long in size; due to its sensitive nature, it should be stored in a configuration file with restricted permissions managed by the Secure Storage APIs provided by the operating system, or even better stored in a [Hardware Security Module](https://en.wikipedia.org/wiki/Hardware_security_module) (HSM).

Two methods are commonly adopted to implementing the pepper. In the simplest case, it would be used similarly to the salt by concatenating it to the password before hashing. A more secure option is to hash the passwords as usual and then encrypt the hashes with a [symmetrical encryption](https://en.wikipedia.org/wiki/Symmetric-key_algorithm) key before storing them in the database, with the key acting as the pepper; this second method allows rotation of the pepper if it was compromised.

As noted by [Wikipedia](https://en.wikipedia.org/wiki/Pepper_%28cryptography%29), "*by including pepper in the hash, one can have the advantages of both methods: uncrackable passwords so long as the pepper remains unknown to the attacker, and even if the pepper is breached, an attacker still has to brute force the hashes*".

###### Password exposure is caused by bad practice
While the methods described above provide a reasonable level of security for storing passwords and other data, unfortunately not all of them are always implemented correctly (and oftentimes some of them are not implemented at all). A glance at the list of [most notable website breaches](https://haveibeenpwned.com/PwnedWebsites) available on the website HaveIBeenPwned highlights how the largest amount of damage has been suffered by sites that did not follow the guidelines and best practices for data security, despite them being known and consolidated for more than two decades: it is quite safe to say that, if passwords and sensitive user data is exposed, that depends only on negligent implementation and lack of care by the companies that we trust our data with.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 118 others
properties (23)
authorlucabarbera
permlinkdigital-authentication-how-passwords-are-safely-stored-online
categoryhive-175254
json_metadata"{"app":"peakd/2020.08.3","format":"markdown","description":"A technical overview of best practices to protect data against hackers attack.","tags":["encryption","technology","blog"],"links":["https://en.wikipedia.org/wiki/List_of_data_breaches","https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#Use_a_cryptographically_strong_credential-specific_salt","https://en.wikipedia.org/wiki/Hardware_security_module","https://en.wikipedia.org/wiki/Symmetric-key_algorithm","https://en.wikipedia.org/wiki/Pepper_%28cryptography%29","https://haveibeenpwned.com/PwnedWebsites"],"image":["https://files.peakd.com/file/peakd-hive/lucabarbera/bGU857sF-image.png"]}"
created2020-09-07 08:02:18
last_update2020-09-07 08:21:45
depth0
children10
last_payout2020-09-14 08:02:18
cashout_time1969-12-31 23:59:59
total_payout_value2.882 HBD
curator_payout_value3.808 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,696
author_reputation8,068,318,645,553
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries
0.
accounthiveonboard
weight100
1.
accountoracle-d
weight100
2.
accountpeakd
weight300
3.
accountph-fund
weight2,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,496,231
net_rshares23,793,350,805,430
author_curate_reward""
vote details (182)
@alexbalan ·
Great insight into keeping passwords secure on the server. It was a pleasant read and I even learned a thing or two even though I was familiar with most concepts. Great job!
properties (22)
authoralexbalan
permlinkqgd222
categoryhive-175254
json_metadata{"app":"hiveblog/0.1"}
created2020-09-08 22:20:27
last_update2020-09-08 22:20:27
depth1
children1
last_payout2020-09-15 22:20:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length173
author_reputation7,291,343,466,873
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,525,448
net_rshares0
@lucabarbera ·
I have published another article in this series, focusing on why everybody has been using insecure passwords in the last 20 years, hope you may find it interesting: https://peakd.com/hive-175254/@lucabarbera/your-insecure-passwords-and-where-to-find-them .
properties (22)
authorlucabarbera
permlinkre-alexbalan-qghn1c
categoryhive-175254
json_metadata{"tags":["hive-175254"],"app":"peakd/2020.09.2"}
created2020-09-11 09:44:03
last_update2020-09-11 09:44:03
depth2
children0
last_payout2020-09-18 09:44:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length256
author_reputation8,068,318,645,553
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,567,715
net_rshares0
@creativeblue ·
@tipu curate
properties (22)
authorcreativeblue
permlinkqgazsl
categoryhive-175254
json_metadata{"users":["tipu"],"app":"hiveblog/0.1"}
created2020-09-07 19:04:03
last_update2020-09-07 19:04:03
depth1
children1
last_payout2020-09-14 19:04:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation-9,592,728,153,451
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,505,347
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?creativeblue" target="_blank">Upvoted  &#128076;</a> (Mana: 8/32)
properties (22)
authortipu
permlinkre-qgazsl-20200907t190415
categoryhive-175254
json_metadata""
created2020-09-07 19:04:15
last_update2020-09-07 19:04:15
depth2
children0
last_payout2020-09-14 19:04:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length107
author_reputation55,937,652,527,393
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,505,348
net_rshares0
@fijimermaid ·
This. Was. Great. @lucabarbera!  
 I learned quite a bit from this.
properties (22)
authorfijimermaid
permlinkqgcuod
categoryhive-175254
json_metadata{"users":["lucabarbera"],"app":"hiveblog/0.1"}
created2020-09-08 19:41:00
last_update2020-09-08 19:41:00
depth1
children1
last_payout2020-09-15 19:41:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length67
author_reputation46,707,719,533,155
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,523,310
net_rshares0
@lucabarbera ·
Thank you! I'm always hoping my articles can be informative and useful. It feels good to know they are appreciated.
properties (22)
authorlucabarbera
permlinkre-fijimermaid-qgcv3l
categoryhive-175254
json_metadata{"tags":["hive-175254"],"app":"peakd/2020.08.3"}
created2020-09-08 19:50:18
last_update2020-09-08 19:50:18
depth2
children0
last_payout2020-09-15 19:50:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length115
author_reputation8,068,318,645,553
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,523,475
net_rshares0
@gitplait ·
Upvoted by GITPLAIT!

We have a curation trial on Hive.vote. you can earn a passive income by delegating to [@gitplait](https://hive.vote/dash.php?i=15&id=1&user=gitplait)
We share 80 % of the curation rewards with the delegators.
___

_To delegate, use the links or adjust_ [10HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=10%20HP), [20HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=20%20HP), [50HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=50%20HP), [100HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=100%20HP),   [200HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=200%20HP), [500HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=500%20HP), [1,000HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=1000%20HP), [10,000HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=10000%20HP), [100,000HIVE](https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=100000%20HP)

___

Join the [Community](https://hive.blog/trending/hive-103590) and chat with us on [Discord](https://discord.gg/CWCj3rw)  let’s solve problems & build together.
properties (22)
authorgitplait
permlinkqgaxil
categoryhive-175254
json_metadata{"links":["https://hive.vote/dash.php?i=15&id=1&user=gitplait","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=10%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=20%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=50%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=100%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=200%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=500%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=1000%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=10000%20HP","https://hivesigner.com/sign/delegateVestingShares?delegator=&delegatee=gitplait&vesting_shares=100000%20HP","https://hive.blog/trending/hive-103590","https://discord.gg/CWCj3rw"],"app":"hiveblog/0.1"}
created2020-09-07 18:47:21
last_update2020-09-07 18:47:21
depth1
children0
last_payout2020-09-14 18:47:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,493
author_reputation911,220,543,569
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,505,066
net_rshares0
@hivebuzz ·
Congratulations @lucabarbera! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@lucabarbera/upvoted.png?202009071641"></td><td>You received more than 1250 upvotes. Your next target is to reach 1500 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@lucabarbera) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the last post from @hivebuzz:**
<table><tr><td><a href="/hive-151781/@hivebuzz/meetup-uk"><img src="https://images.hive.blog/64x128/https://i.imgur.com/h6W1RRo.png"></a></td><td><a href="/hive-151781/@hivebuzz/meetup-uk">HiveBuzz supports meetups of the Hive UK Community</a></td></tr><tr><td><a href="/hivebuzz/@hivebuzz/feedback-from-the-september-1st-hive-power-up-day"><img src="https://images.hive.blog/64x128/https://i.imgur.com/zHjYI1k.jpg"></a></td><td><a href="/hivebuzz/@hivebuzz/feedback-from-the-september-1st-hive-power-up-day">Feedback from the September 1st Hive Power Up Day</a></td></tr></table>
properties (22)
authorhivebuzz
permlinkhivebuzz-notify-lucabarbera-20200907t164856000z
categoryhive-175254
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2020-09-07 16:48:54
last_update2020-09-07 16:48:54
depth1
children0
last_payout2020-09-14 16:48:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,263
author_reputation369,411,709,912,362
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,503,206
net_rshares0
@team07 ·
Wonderful article. Thanks for sharing such a nice topics.
properties (22)
authorteam07
permlinkqgatb3
categoryhive-175254
json_metadata{"app":"hiveblog/0.1"}
created2020-09-07 17:16:18
last_update2020-09-07 17:16:18
depth1
children1
last_payout2020-09-14 17:16:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length57
author_reputation15,893,100,901,937
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,503,609
net_rshares0
@lucabarbera ·
Thank you! I thought it could be useful to share the knowledge for everyone's benefit, as this is usually not taught on computer classes or explained in layman's terms outside of tech documents.
properties (22)
authorlucabarbera
permlinkre-team07-qgbugm
categoryhive-175254
json_metadata{"tags":["hive-175254"],"app":"peakd/2020.08.3"}
created2020-09-08 06:39:03
last_update2020-09-08 06:39:03
depth2
children0
last_payout2020-09-15 06:39:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length194
author_reputation8,068,318,645,553
root_title"Digital authentication: how passwords are safely stored online"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,513,499
net_rshares0