{"id":2309,"date":"2014-03-31T11:00:53","date_gmt":"2014-03-31T15:00:53","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=2309"},"modified":"2014-11-13T12:31:13","modified_gmt":"2014-11-13T17:31:13","slug":"salt","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/2309\/salt\/","title":{"rendered":"Salt \u2013 Preventing Rainbow Attacks against Password Stores"},"content":{"rendered":"<div>\n<div style=\"float:left;padding:20px;\"> <a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg\" alt=\"rainbow salt\" title=\"rainbow salt\" width=\"320\" height=\"210\" class=\"aligncenter size-full wp-image-2310\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg 480w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt-300x196.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt-150x98.jpg 150w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/div>\n<h3>Introduction<\/h3>\n<p>\nIn my article about <a href=\"http:\/\/sqlity.net\/en\/2303\/cryptographic-hash\/\">cryptographic hash functions<\/a> I mentioned that hash functions often are used to store passwords in the database. Today I would like to spend a little more time on how to store passwords securely.\n<\/p>\n<h3>Password Lists<\/h3>\n<p>\nIt has become a common place to read in the news about this or that website being hacked. Such news usually contain the advice to change your password, not only on the hacked site, but on every other site where you might have used a similar password. Why is that the case?\n<\/p>\n<p>\nWell, most of us are still humans and therefore have a limited capacity for remembering passwords. However, the number of places we need to authenticate with is ever growing. That leads to most people using the same password in more than one place. Because of that, it is lucrative for criminals to spend some effort on creating a list of email addresses, login names and passwords. With that information, they are able to logon to other services like your bank and cause some real damage.\n<\/p>\n<p>\nMany websites still make it very easy for intruders to compile such a list because they do store passwords in clear text. Using a cryptographic hash function to hash the password before storing it makes it a little harder for criminals to compile that list. However even a hashed password list is not a high hurdle to overcome.\n<\/p>\n<h3>Rainbow Tables<\/h3>\n<p>\nWith storage prices as low as they are it is easy for an attacker to pre-calculate the hash values of millions of common passwords. A list of password hashes like this is called a rainbow table. (Actually, a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Rainbow_table\">rainbow table<\/a> is a little more complex than just a list of pre-computed hashes to save some storage space, but  for the purpose of the article that detail is not relevant.)\n<\/p>\n<p>\nSuch a pre-computed hash table allows an attacker to quickly scan through the list of stored password hashes to retrieve matching passwords and their account names and email addresses. An attack using this method is called a Rainbow Attack. There is however a simple way to make this type of attack infeasible: Salting your passwords.\n<\/p>\n<h3>Salt for the Password Soup<\/h3>\n<p>\nA Salt is a random string that is appended to the value we want to hash (the password) before the hash function is applied. The salt does not need to be secret. However, it must be unpredictable and reasonable long. Unpredictable means, it is not derived from the password itself and it is different for each stored password. A <A href=\"http:\/\/sqlity.net\/en\/2209\/pseudo-random\/\">CSPRNG<\/a> is a good choice for generating your salt values. The salt must be stored together with the hashed password, as you will need it during authenticating requests.\n<\/p>\n<p>\nBecause a password now turns into completely different hash values depending on the salt, to still be able to use a rainbow table the attacker would have to create one table for each possible salt value. With 12 bits of salt (used by early Unix systems) that would mean 4096 different tables. That is actually quite achievable on modern storage devices. However, with for example 64 bits of salt this will be impossible for quite a while. Never the less, there are security experts recommending to use a salt at least as long as the resulting hash value, so for example 512 bits for the SHA2_512 algorithm.\n<\/p>\n<h3>Additional Measures<\/h3>\n<p>\nWhile a salt effectively prevents the use of a rainbow table, it does not make it in any way more difficult to attack a single password hash. To achieve that, the hash function itself has to be made computationally more expensive. While a user will most likely not notice, if the authentication takes an additional half second, an attacker who on average has to test tens of millions of possible passwords before a match is found, can now only test about 173 thousand passwords in a day (on a single thread). Two common passwords hashing methods that are designed to use a salt and be computationally expensive are bcrypt and PBKDF2. PBKDF2 is for example used to store passwords in WPA2 Wi-Fi routers.\n<\/p>\n<h3>Summary<\/h3>\n<p>\nDecrypting large password lists is a very lucrative business for criminals, as most users reuse the same password across many sites. When you have to store passwords, always use a cryptographic hash function on the password concatenated with a random salt, before storing it anywhere. If done correctly, this will effectively prevent large-scale attacks employing rainbow tables against your password list.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is a Salt Value and how does it help to protect the stored passwords of your application&#8217;s users from attacks involving Rainbow Tables? Read on to find out now.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/2309\/salt\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[139,32,5,34,27],"tags":[273,152,146,153,151,38],"class_list":["post-2309","post","type-post","status-publish","format-standard","hentry","category-cryptographic-terminology","category-cryptography","category-general","category-security","category-series","tag-cryptography","tag-hash","tag-hash-function","tag-password","tag-salt","tag-security-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net<\/title>\n<meta name=\"description\" content=\"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/2309\/salt\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/2309\/salt\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-31T15:00:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T17:31:13+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"Salt \u2013 Preventing Rainbow Attacks against Password Stores\",\"datePublished\":\"2014-03-31T15:00:53+00:00\",\"dateModified\":\"2014-11-13T17:31:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/\"},\"wordCount\":749,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/rainbow_salt.jpg\",\"keywords\":[\"Cryptography\",\"hash\",\"Hash Function\",\"password\",\"salt\",\"security\"],\"articleSection\":[\"Cryptographic Terminology\",\"Cryptography\",\"General\",\"Security\",\"Series\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/\",\"name\":\"Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/rainbow_salt.jpg\",\"datePublished\":\"2014-03-31T15:00:53+00:00\",\"dateModified\":\"2014-11-13T17:31:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#primaryimage\",\"url\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/rainbow_salt.jpg\",\"contentUrl\":\"http:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/rainbow_salt.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2309\\\/salt\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salt \u2013 Preventing Rainbow Attacks against Password Stores\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net","description":"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sqlity.net\/en\/2309\/salt\/","og_locale":"en_US","og_type":"article","og_title":"Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net","og_description":"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.","og_url":"https:\/\/sqlity.net\/en\/2309\/salt\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2014-03-31T15:00:53+00:00","article_modified_time":"2014-11-13T17:31:13+00:00","og_image":[{"url":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg","type":"","width":"","height":""}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"Salt \u2013 Preventing Rainbow Attacks against Password Stores","datePublished":"2014-03-31T15:00:53+00:00","dateModified":"2014-11-13T17:31:13+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/"},"wordCount":749,"commentCount":3,"image":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg","keywords":["Cryptography","hash","Hash Function","password","salt","security"],"articleSection":["Cryptographic Terminology","Cryptography","General","Security","Series"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/2309\/salt\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/2309\/salt\/","url":"https:\/\/sqlity.net\/en\/2309\/salt\/","name":"Salt \u2013 Preventing Rainbow Attacks against Password Stores - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#primaryimage"},"thumbnailUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg","datePublished":"2014-03-31T15:00:53+00:00","dateModified":"2014-11-13T17:31:13+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"What is a Salt Value and how does it help to protect your stored passwords from attacks involving Rainbow Tables? Click to find out now.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/2309\/salt\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#primaryimage","url":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg","contentUrl":"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/03\/rainbow_salt.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/2309\/salt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"Salt \u2013 Preventing Rainbow Attacks against Password Stores"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s2wXuw-salt","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=2309"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2309\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=2309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=2309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=2309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}