Safe coding: safe password with salt, pepper and hashing

0
16
Safe coding: safe password with salt, pepper and hashing


Safe coding contribution “Password hasing is already shown to protect the password from the brut force and rainbow tables” that why the password should never be stored directly, but the firmness layer should be saved as the hash value in the layer. It was also discussed that the importance of significant striking strings was important in hashing to increase security. The following article now shows what developers should consider when making and applying salt values.

Advertisement





Since 1996, Swen Java has been programming in industrial projects and has been programming for more than 15 years in industries such as automobile, space travel, insurance, banks, UN and World Bank for 15 years. He has been in conferences and community programs from the US to New Zealand for 10 years, worked as a developer lawyer for JFROG and Vaadin and regularly writes posts for IT magazines and technology portals. In addition to its main theme Core Java, he belongs to TDD and safe coding practices.

As a small recurrence: Password ishing is a mashing password is an essential technique for secure storage. Instead of removing a password in plain text, it is converted into a string through a disposable hash function, which cannot be easily rebuilt. The password is protected from unauthorized access, even if a database is compromised.

Since the same passwords always result in calculation, for example, the same ish, just that users can find out which users use the same password by comparing itash. It facilitates massive and targeted attacks on specific users. For high security, the so -called salt price comes in the game, a random string that is associated with a password before the hashch calculation. Separate hash values ​​for the same password can also be generated and security against various attack techniques such as rainbow tables can be increased.

Rainbow tables-taiyar table hash values ​​to make a password as efficiently to the general password-utility attackers with their hash as much efficiently. However, if a salt value is added to the hash calculation, the password is no longer possible. In addition, the salt value protects the so -called dictionary attacks, in which the attackers try to try a list of frequently used passwords to compensate for their hash in a stolen database.

First, it is important for safe handling of salt values ​​to use a unique salt value for each password. Second, the value should be random and sufficiently long. A length of at least 16 bytes is recommended to avoid the risk of conflict and estimated pattern. In addition, cryptographically safe random number generators ensure that salt values ​​cannot be estimated. Third, the salt value should be saved with a password held. Since this is not a secret information, if it is open to the public then there is no risk. However, it should not be reused several times for various passwords.

HashiCorp: New names and features for Terraform, Packer, and VaultHashiCorp: New names and features for Terraform, Packer, and Vault

To tighten the hashing process against cruel force attacks, arithmetic-intensive hash algorithms are recommended-they set obstacles for attacks due to frequent calculations. Finally, a black pepper value can also be used in addition to salt, which is stored as a secret key on the server side and not saved with hash data. Regular safety checks, updates of hashing methods and adjustment of parameters such as the number of recommendations recommended.

The value of black pepper is a secret key that is used in combination with passwords to increase the safety of the Haching Process. Unlike the salt value, which is generated and saved individually for each password, the value of pepper remains the same for all passwords of a system and saved separately, for example in server configuration.

The main objective is to make attacks on values ​​more difficult. If an attacker achieves access to the database with password-blessings, he cannot easily understand the hash because the value of pepper is not stored in the database. This makes it more difficult for the attackers to crack the hash due to already mentioned dictionary or brutal force attacks, as they do not have an essential part of the calculation.

Another advantage of the value of black pepper is that it can be regularly replaced to prevent long -stricken hashs from compromising if an attacker gives himself access to old data records.

Unlike salt values, pepper value should not be saved in the database, but should be safely stored in server configuration or special safety solutions such as hardware security modules (HSMs). In addition, the value of black pepper should be saved directly into the hardware for the operation of the source code or application at any time. Instead, the use of a safe environmental variable or a mystery management system is recommended. This ensures that the attackers achieving access to the database also do not capture the value of pepper.

An important aspect is also a regular update of black pepper value. Since it (often, but not mandatory) is the same for all passwords of a system, it must be replaced at regular intervals to ensure long -term safety. However, this requires a new hash calculation for all stored passwords, which must be according to a well thought out rotary mechanism.

The use of black pepper values ​​is only intelligent in relation to password ishing and salt values. The value of a pepper alone does not increase security.

There is a clash in relation to the hashing when two different input values ​​generate the same haveh value. When storing the password, they represent a safety risk. One talks about one Collision,

Since hash functions also have a limited amount of output, while the amount of potential input is infinitely large, collisions are theoretically indispensable. In practice, however, the possibility of collision can be minimized by choosing a suitable cryptographic hash function. Old algorithms such as MD5 or SHA-1 are considered unsafe, as they already have practical conflict attacks. In 2017, the Shaattered project showed that the Sha 1 confrontation can be generated already with comparatively moderate arithmetic resources. MD5 is even easier to reach confrontation. Only new algorithms such as SHA-256 or Argon2 provide adequate protection. With the SHA-256, for example, 2^128 attempts are required to find a collision. The possibility of a collision attack is extremely rare.

Special care is required to ensure both safety and user-moistilderness to deal with old salt and pepper values ​​as well as password-blessings in a system. Developers should fall back on the following proven procedures.

First of all, it should be ensured that old hash algorithms or uncertain methods are gradually replaced by more modern people. If a weak hash algorithm is still used, a migration process should be applied, in which passwords are once again hydrovers and are saved with a strong algorithm and a new salt.

Old salt values ​​can be used until they are sufficient. However, if you are too low or approximate, you should be replaced by new, safe salt values. This can also be done next time to enable a user login or password change to enable a phase -B -step change.

Black pepper values ​​should be updated regularly to increase security. Since new black pepper values ​​cannot be used rebuilt for the old hash, the update should be stepped into steps by adding new passwords to the new pepper hash, while the old is tested regularly. To reduce the risk of compromising, chronic pepper values ​​should not be saved permanently, but only until all affected passwords are updated with a new black pepper haveh.

Alternatively, complete renewal of all hash can be forced to reset your password after a certain time or after safety warning. This ensures that all passwords are stored on the basis of the latest security standards.

Last but at least, it is advisable not to keep the old hash unlimited. After a proper transition period and after ensuring that all users have updated their passwords, the old hash should be safely removed to reduce the risk of misconduct.

There are various strategies for password-migration that differ in relation to user-friendship, economy and security:

Migration on the next login slowly

With this method, the switch of a safe ishing process automatically occurs in the background as the user registers. The system load remains moderate because only active users are affected. However, this means that the older uncertain hash remains in the system until a user logs in – inactive users do not benefit from migration, and have a longer period of time with less safe haveing.

Forced password update

This method ensures that all users must immediately change their password to ensure that they are saved with current and safe haveh. Possible security problems can be fixed early in this way. However, this support can increase the endeavor and make users offend if problems arise during changes and possibly passwords must be reset several times.

Automatic Reconstruction of all hash

With this method, all stored passwords are immediately switched to a safe standard without required user interactions. This ensures that all passwords meet the latest security requirements. However, there are challenges: If the hashing method uses black pepper value, renovation cannot be renovated without knowledge of plain text passwords. In addition, this strategy requires a high resource effort, as the entire database migration should be performed at one time, which can at least temporarily cause loss of performance.

Hybrid strategy

This method combines the benefits of gradual and forced migration. While active users are automatically switched to the new hashing process when login is the next login, older or passive accounts to change password changes to switch to the new safety standard. On the one hand, the process reduces the load on the system, but still ensures a wide update. However, this strategy is accompanied by more complex implementation as different user groups have to behave differently.

Carefully selection of migration strategy, keeping in mind the described factors, increases the safety of the system without user -friendship or unnecessarily affecting the economy.

Product Activists: The AARRR Model — How Pirate Metrics Help Product OwnersProduct Activists: The AARRR Model — How Pirate Metrics Help Product Owners

LEAVE A REPLY

Please enter your comment!
Please enter your name here