{"id":15671,"date":"2022-08-01T18:02:47","date_gmt":"2022-08-01T22:02:47","guid":{"rendered":"https:\/\/www.thesslstore.com\/blog\/?p=15671"},"modified":"2023-05-24T11:03:44","modified_gmt":"2023-05-24T15:03:44","slug":"password-salting-a-savory-way-to-secure-your-secrets","status":"publish","type":"post","link":"https:\/\/www.thesslstore.com\/blog\/password-salting-a-savory-way-to-secure-your-secrets\/","title":{"rendered":"Password Salting: A Savory Way to Secure Your Secrets"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-password-salt-is-a-critical-element-of-database-security-without-password-salting-any-password-hashes-you-store-on-your-server-are-susceptible-to-dictionary-rainbow-table-attacks-and-risk-compromise-that-can-land-your-organization-in-some-devastating-headlines\">Password salt is a critical element of database security. Without password salting, any password hashes you store on your server are susceptible to dictionary &amp; rainbow table attacks and risk compromise that can land your organization in some devastating headlines<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When many people think about password security, there\u2019s often a misconception that you should encrypt your secrets in order to keep them secure on your server. But when it comes to passwords, encryption isn\u2019t the solution; there\u2019s another cryptographic process that\u2019s far better suited for the task. This involves salting passwords and then hashing them to store their hash values instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ve briefly talked before about the <a href=\"https:\/\/www.thesslstore.com\/blog\/difference-encryption-hashing-salting\/\">difference between encryption, hashing, and salting<\/a> and the relationship of the latter two to password security. But we figure that it\u2019s a topic that deserves a little more TLC and attention than it\u2019s gotten in the past. So, here we are with a new article that will dive more in depth into salted password hashing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But what is password salting and why is it so critical to secure password storage?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s hash it out.<span id=\"newline\"><\/span><\/p>\n\n\n<span style=\"--tl-form-height-m:150.25px;--tl-form-height-t:121.4583px;--tl-form-height-d:121.4583px;\" class=\"tl-placeholder-f-type-shortcode_12753 tl-preload-form\"><span><\/span><\/span>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-password-salting-a-password-salt-definition\">What Is Password Salting? A Password Salt Definition<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Password salting is the process of adding a random, unique integer or string to every password to prior to hashing it. A salt is a random, large, unique value that\u2019s generated using a cryptographically secure random number generator (RNG), or what\u2019s sometimes called a <a href=\"https:\/\/nvlpubs.nist.gov\/nistpubs\/Legacy\/SP\/nistspecialpublication800-132.pdf\">random bit generator<\/a> (RBG). Salts are traditionally stored on your server alongside your password hash values. &nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s an example of salts that were auto generated and added to a WordPress config.php file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"332\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/wordpress-salts-example-shadow-1024x332.png\" alt=\"A screenshot example of WordPress salts\" class=\"wp-image-15673\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/wordpress-salts-example-shadow-1024x332.png 1024w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/wordpress-salts-example-shadow-300x97.png 300w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/wordpress-salts-example-shadow-768x249.png 768w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/wordpress-salts-example-shadow.png 1259w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\"><em>Image caption: No, you\u2019re not having vision issues. We\u2019ve blurred the main portion of the WordPress salted hash values that serve as an example of a salt string of data.<\/em><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">More technically speaking, the Internet Engineering Task Force (IETF) Network Working Group\u2019s <a href=\"https:\/\/www.rfc-editor.org\/rfc\/pdfrfc\/rfc4949.txt.pdf\">Request for Comments (RFC) 4949<\/a> defines a salt as:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><em>\u201cA data value used to vary the results of a computation in a security mechanism, so that an exposed computational result from one instance of applying the mechanism cannot be reused by an attacker in another instance.\u201d<\/em><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">But what\u2019s the point of using a password salt? Password salting allows you to create a unique hash value for every password. A hash is a method of taking an input of any size and converting into a random string of gibberish of the same length. This masks the size and any identifying information about the original input and can be used for data integrity verification. This helps to secure your stored password hashes against dictionary attacks (a type of brute force attack) and rainbow table attacks should cybercriminals get their grubby hands on your database. (We\u2019ll speak more to the reasons why a little later in the article.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Basically, the big takeaway here is that storing salted password hashes instead of plaintext passwords or unsalted password hashes is the difference between:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enabling attackers to easily search your database for plaintext passwords or hash values that match common passwords, and<\/li>\n\n\n\n<li>Making it too impractical and cumbersome to figure out individually.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">(Don\u2019t worry, we\u2019ll speak more to hashing in a minute or two. And, no, hashing isn\u2019t the same thing as encryption.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The idea here is that you\u2019re enabling every individual password input to have its unique hash value by salting your passwords before hashing them. This means that their hash values will be entirely different even if you have two separate users using identical passwords (say, <em>password123<\/em>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course, you want to make sure that no one knows which salt you\u2019ve used. This is why you need to add a unique, randomly generated salt to each password before hashing it. While it\u2019s true that the salt gets stored next to your password hashes, it would be too time consuming and labor intensive to try to calculate each password using each individual salt. Taking that individual approach wouldn\u2019t be worth it to cybercriminals who are trying to crack thousands or even millions of common passwords quickly using scripts and automation. &nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-an-example-of-how-salting-alters-your-password-hash-value\">An Example of How Salting Alters Your Password Hash Value<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ideally, users should be using unique passwords or passphrases to secure their accounts. But we know that not everyone follows <a href=\"https:\/\/www.thesslstore.com\/blog\/password-security-what-your-organization-needs-to-know\/\">password security<\/a> best practices and will sometimes use common passwords. This is why it\u2019s important to salt your passwords; it prevents a hacker from simply searching your database for password hashes that match the hashes of common passwords.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Knowing this, let\u2019s explore a quick example of how an MD5 salted hash value looks using the common password <em>password123<\/em> as an example<em>:<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>48<em><em>2c811da5d5b4bc6d497ffa98491e38<\/em><\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, let\u2019s consider what happens when you apply the salt value <em>+Oa8kFpYobjX<\/em> to the same password. It results in the following entirely unique hash value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em>e72fd887c202a4367b8a96d42d1a1e10<\/em><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Without salting, two separate users would wind up having identical password hash digests. This would be bad news because it means that if a user\u2019s password gets compromised in a data breach, hackers can use that known value to check against known hash values until they find a match.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But why would two users with identical passwords wind up with the same hash digest? This is because <strong>strong hashes are deterministic in nature<\/strong>. What this means is that any given input (i.e., your plaintext password) will always return the same hash value. So, a password like <em>password123<\/em> will always return the same hash value when using the same hash function unless you do something to change the input, even just a little bit:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For example, if you changed a capitalization in the password password123 and made it PassWord123, it would generate an entirely different hash value (<em>28d2464b121f120a41f4cd5c496cae2c<\/em>).<\/li>\n\n\n\n<li>If you take the same original password and just add a salt to it, as we explored in the example a few moments ago, it\u2019ll create an entirely unique hash value. &nbsp;<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">But salting isn\u2019t the only way to add additional values to your passwords to increase their security. There\u2019s also a related, lesser-known cryptographic process known as peppering.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-password-salting-vs-peppering-in-cryptography\">Password Salting vs Peppering in Cryptography<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/saltpepper.png\" alt=\"A graphic that explains that salts and peppers are both values that can be added to plaintext passwords prior to hashing to increase the security of secrets.\" class=\"wp-image-15675\" width=\"349\" height=\"330\" srcset=\"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/saltpepper.png 589w, https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/saltpepper-300x284.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Something that\u2019s very common in cryptography \u2014 and cybersecurity in general \u2014 is that different terms are sometimes used interchangeably. This is the case with salt and pepper \u2014 while they\u2019re related, they\u2019re not the same thing and should be treated as separate elements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, a pepper is kind of like a salt in that it\u2019s a value (a large integer or string) you tack onto passwords to add another layer of security. But, unlike a salt, a pepper is a secret value that can be reused. According to the Internet Engineering Task Force (IETF), a pepper is a value that can be reused over and over again.) Furthermore, because they\u2019re intended to remain secret, peppers shouldn\u2019t be stored along with the password hashes in your database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/www.ietf.org\/archive\/id\/draft-ietf-kitten-password-storage-04.html\">IETF also says that peppers should be able to be rotated<\/a> and swapped out with alternate peppers:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><em>\u201cIf a pepper is used, consideration should be taken to ensure that it can be easily rotated. For example, multiple peppers could be stored. New passwords and reset passwords would use the newest pepper and a hash of the pepper using a cryptographically secure hash function such as SHA256 could then be stored in the database next to the salt so that future logins can identify which pepper in the list was used.\u201d&nbsp;<\/em><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">IETF also warns that peppers and salts should not be combined because the salt isn\u2019t a secret value; therefore, it may appear in the final hash value output.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&nbsp;<\/td><td><strong>Password Salt<\/strong><\/td><td><strong>Password Pepper<\/strong><\/td><\/tr><tr><td><strong>Minimum Length<\/strong><\/td><td>16 bytes (128 bits)<\/td><td>32 bytes (256 bits)<\/td><\/tr><tr><td><strong>What It Is<\/strong><\/td><td>A randomly generated integer or string that\u2019s combined with a password prior to hashing to create a unique hash value<\/td><td>A recyclable value that can be reused for multiple password hashes. This recyclable integer is kept secret so it\u2019s reusable.<\/td><\/tr><tr><td><strong>Storage Methods<\/strong><\/td><td>Salts are stored alongside the passwords\u2019 hash values in your database<\/td><td>Peppers are typically not stored with the passwords; however, it sometimes can be stored separately (typically though hard coding)<\/td><\/tr><tr><td><strong>Where a Salt or Pepper Value Gets Placed<\/strong><\/td><td>Typically added at the beginning or end of the plaintext password input &nbsp;<\/td><td>Typically added at the end of the plaintext input<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So now that we know what salt and pepper are (aside from two tasty spices and the naming inspiration of a female 80s\/90s hip-hop duo), it\u2019s time to see where they fit in terms of cryptography \u2014 more specifically, within terms of hashing passwords and password security.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hashing-serves-as-a-one-way-cryptographic-function\">Hashing Serves as a One-Way Cryptographic Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Hashing is a cryptographic function that converts a plaintext input into a fixed length string of random characters. This means you could take the content from <em>every website on the internet<\/em>, combine it all together, hash it, and the resulting string of hexadecimal characters would be the same length as an input that\u2019s the sentence \u201cG\u2019day, mate!\u201d Crazy, huh?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The purpose of hashing is to serve as a one-way method of verification. It allows you to confirm whether an input has been altered in any way since it was originally processed. It\u2019s often used in combination with digital signatures, which are also cryptographic elements that, essentially, attach the digital identity of an organization or individual to the data in question. Using a digital signature offers assurances that the data is authentic because it came from the legitimate person or entity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hashing is a cryptographic process that is practically irreversible. What we mean by this is that it requires too many resources and too much time to try to use modern computers to take a hash digest and try to figure out its original input. This differs from encryption, which is intended to serve as a two-way function \u2014 meaning that the intention of encrypting data is for an authorized user (i.e., a private key holder) to be able to decrypt the data on the receiving end.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hashing is used in a variety of functions, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating password hash values that can be stored in lieu of plaintext passwords<\/li>\n\n\n\n<li>Ensuring the integrity of code, software, and other executables through code signing<\/li>\n\n\n\n<li>Ensuring the integrity of email messages (via S\/MIME certificates)<\/li>\n\n\n\n<li>Protecting the integrity of data transmitted between users and web servers (via SSL\/TLS connections)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-why-storing-only-salted-password-hashes-matters-in-password-security\">Why Storing Only Salted Password Hashes Matters in Password Security<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Storing salted hash values means that the original plaintext inputs are never uploaded to the server. This helps to protect them against dictionary and rainbow table attacks. It also makes them inaccessible to both your employees (who can\u2019t inadvertently give access to your database that houses them by falling for phishing scams) and cybercriminals (who use various hacking or social engineering methods to gain access to the database).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s compare three approaches to storing login credential-related information to see which method is the most secure:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Storing plaintext passwords.<\/strong> If you opt to save the plaintext passwords in a database on your server, then you run the risk of those passwords being compromised via <a href=\"https:\/\/www.thesslstore.com\/blog\/sql-injection-attack-what-it-is-how-to-protect-your-business\/\">SQL injections<\/a>, <a href=\"https:\/\/www.thesslstore.com\/blog\/xml-injection-attacks-what-to-know-about-xpath-xquery-xxe-more\/\">XML injection attacks<\/a> and other similar scenarios. &nbsp;<\/li>\n\n\n\n<li><strong>Storing unsalted password hashes.<\/strong> This method involves only storing the hash values that are generated by applying a hash function to the passwords. This can result in multiple users sharing the same hash value because their inputs (i.e., their passwords) were identical. This method leaves their credentials vulnerable to <a href=\"https:\/\/www.thesslstore.com\/blog\/rainbow-tables-a-path-to-password-gold-for-cybercriminals\/\">rainbow table attacks<\/a> and a type of <a href=\"https:\/\/www.thesslstore.com\/blog\/brute-force-attack-definition-how-brute-force-works\/\">brute force attack<\/a> known as a dictionary attack.&nbsp;<\/li>\n\n\n\n<li><strong>Storing salted password hashes.<\/strong> This method only involves storing the entirely unique hash values, which are practically irreversible because of the sheer processing power and time required. Furthermore, since adding a salt creates a unique hash value, rainbow table attacks are ineffective.<\/li>\n<\/ul>\n\n\n<span style=\"--tl-form-height-m:861.156px;--tl-form-height-t:899.625px;--tl-form-height-d:899.625px;\" class=\"tl-placeholder-f-type-shortcode_12653 tl-preload-form\"><span><\/span><\/span>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-tl-dr-here-are-your-password-salting-highlights\">TL;DR? Here Are Your Password Salting Highlights<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This article isn\u2019t one of our usual tomes that dives super in-depth into a topic, but that doesn\u2019t mean that you have 15 minutes to read the technical nitty-gritty of it, either. That\u2019s why we\u2019ve got your overview right here on password salting and your organization needs to do it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Password salting is considered a password security best practice by the Internet Engineering Task Force.&nbsp;<\/li>\n\n\n\n<li>A salt itself is created entirely (or in part) via an approved random bit generator.<\/li>\n\n\n\n<li>Salted password hashing is a way to securely store credential-related information in a way that doesn\u2019t jeopardize the security of the passwords themselves.<\/li>\n\n\n\n<li>Adding entirely unique salts to a list of passwords prior to hashing makes it so that even if two users have the same secret, each will have a unique hash value associated with their account.&nbsp;<\/li>\n\n\n\n<li>A \u201csalt hash\u201d (salted hash) is a way to protect your users\u2019 login credentials against dictionary attacks and rainbow tables.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Well, that about wraps things up. We hope you\u2019ve enjoyed this quick exploration of password salting and why using a salt hash is crucial to keeping users\u2019 secrets secure on your server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Password salt is a critical element of database security. Without password salting, any password hashes you store on your server are susceptible to dictionary &amp; rainbow table attacks and risk&#8230;<\/p>\n","protected":false},"author":17,"featured_media":15677,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","tve_updated_post":"","tve_custom_css":"","tve_user_custom_css":"","tve_globals":{},"tcb2_ready":0,"tcb_editor_enabled":0,"tve_landing_page":"","_tve_header":"","_tve_footer":""},"categories":[16,10200],"tags":[13183,4708],"class_list":["post-15671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hashing-out-cyber-security","category-monthly-digest","tag-password-salting","tag-salting","post-with-tags"],"views":11549,"jetpack_featured_media_url":"https:\/\/www.thesslstore.com\/blog\/wp-content\/uploads\/2022\/08\/password-salting-feature.jpg","_links":{"self":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts\/15671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/comments?post=15671"}],"version-history":[{"count":0,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/posts\/15671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/media\/15677"}],"wp:attachment":[{"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/media?parent=15671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/categories?post=15671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thesslstore.com\/blog\/wp-json\/wp\/v2\/tags?post=15671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}