Privacy engineering

Store Passwords with a Purpose-Built Password Hash

Review password storage as a versioned verification system, with a maintained hashing library, measured settings and a migration plan.

Password storage should use a maintained implementation of a password-hashing function, with a documented way to verify existing records and upgrade them over time. Do not build a password store from a general-purpose hash call simply because the output looks unreadable. The design must account for how guesses can be tested if stored records are exposed, how verification affects application capacity and how older records move to a new configuration.

The OWASP Password Storage Cheat Sheet recommends modern adaptive password hashing rather than plaintext or reversible encryption for normal password verification. It discusses Argon2id and other choices, salts, work factors and migration considerations. Consult its current recommendations and your chosen library’s documentation for implementation parameters. The workflow here focuses on reviewing the surrounding system, not inventing cryptography or prescribing one setting for every deployment.

Identify every place that accepts a password

Begin with the application paths that create or change a password. Account creation, password reset, administrative account setup and a legacy import may use different code. A new hashing library on the signup route does not improve a forgotten reset handler that still writes an older representation.

Find the verification paths as well. A web login, a mobile endpoint and an internal service may share the same user database while using different application versions. Record which components need to understand each stored format. This inventory is necessary before a migration because a record written by one component must remain verifiable by the components still authorized to authenticate it.

Use synthetic accounts to inspect the behavior. Do not print real passwords or copy live password records into a shared planning document. The review needs to understand format, algorithm identifiers and code paths; it does not need the contents of a customer’s credential.

Let a maintained library handle the representation

A password record normally needs enough information for the verifier to apply the correct algorithm and parameters. Many established libraries provide an encoded representation that includes those details. Understand the format your implementation uses rather than stripping fields to save space or assembling a custom representation without a reason.

Check the storage column and serialization paths. Truncating an encoded record can make verification fail or create inconsistent behavior between environments. Include a round-trip test that writes a synthetic password record through the actual persistence layer, reads it back and verifies it through the supported library API.

Do not normalize passwords silently unless the authentication design explicitly requires and consistently applies a defined rule. A migration that changes how input is interpreted can lock people out even when the hashing algorithm is correct. Document the accepted input behavior and test it with supported character sets and lengths.

Measure the cost where verification will run

A password-hashing configuration consumes resources deliberately. The useful question is whether the chosen configuration meets the security requirements while remaining operable on the actual infrastructure. A laptop measurement is a starting observation, not evidence of production capacity under concurrent login traffic.

Build a controlled benchmark with synthetic credentials and record the environment, library version and settings. Measure individual verification time and behavior under representative concurrency. Include the application overhead around the hash operation so the team can distinguish the cost of the function from database or network delays.

Avoid using a benchmark as an automatic reason to weaken the configuration. If capacity is inadequate, review the deployment, concurrency controls and authentication flow with the responsible security owner. The tradeoff should be explicit. A system that becomes unavailable under normal load is not well designed, but a fast verification path is not the only objective.

Keep verification behavior separate from account lookup

The application has to find the relevant account and then verify the supplied password. Review how errors and timing are handled across that flow. A good password-hashing choice does not by itself resolve account enumeration, brute-force attempts or session handling.

Use the framework’s documented verification facilities and compare behavior through the complete login endpoint. Do not hand-roll a comparison of intermediate values or expose detailed internal failures to the user. Operational diagnostics should help maintainers investigate without revealing passwords, hashes or unnecessary account information.

Record which additional controls belong to the surrounding authentication system. Rate limits, multifactor authentication and recovery policies have their own requirements and tests. Keeping them visible avoids the misleading conclusion that upgrading the stored hash has completed the entire authentication review.

Plan an upgrade path before changing the default

Suppose a fictional application contains records created by two historical versions. New accounts can use the new default immediately, but existing records still need a verifiable path. The application must know which format it is reading and how to handle it until the migration is complete.

One common design verifies an existing record using its supported format and, after successful authentication, replaces it with a record using the current configuration. Whether that approach fits a system depends on the library and account lifecycle. Inactive accounts may require a different process because they never trigger a successful login.

Write down the retirement condition for the older format. Without one, “temporary compatibility” can last indefinitely. The plan should identify how remaining records are counted, who decides the next action and how affected users regain access through an appropriate recovery process. Do not attempt to recover plaintext from a stored hash in order to migrate it.

Test compatibility with a small migration matrix

A migration test should cover supported old records, newly created records and malformed inputs. Use disposable fixtures generated by the actual supported implementations. Avoid treating a manually edited string as equivalent to every record the older application could have produced.

Fixture Verification expectation Migration expectation
Valid record using current settings Correct password succeeds No unnecessary rewrite
Valid supported older record Correct password succeeds through legacy verification Approved upgrade occurs
Wrong password for any supported record Authentication fails Record is not replaced as a successful login
Truncated or unsupported record Controlled failure No fallback to an unsafe interpretation

Also test concurrent requests for the same account. A password change and a login-triggered upgrade should not overwrite one another incorrectly. The exact concurrency control depends on the persistence model, but the expected result should be part of the design rather than an incidental database outcome.

Treat additional secrets as operational commitments

Some designs add a separately stored secret to the password-verification process. Such a choice creates responsibilities for access control, availability, rotation and recovery. It should not be introduced merely because an extra secret sounds like a free improvement.

If the design uses one, document where it lives, which components can use it and what happens when it becomes unavailable or is believed to be compromised. Keep it separate from the password database according to the approved architecture. Test recovery using nonproduction material before relying on a procedure that has never been exercised.

The key-management guide helps frame those operational questions. It does not mean password hashes should be replaced with reversible encryption; the two systems serve different purposes.

Check the paths that can bypass the password

Password reset, recovery links and administrative overrides can change account access without knowledge of the current password. Review them alongside the storage migration so the new scheme does not leave an inconsistent or easier path around normal verification.

Confirm what happens to existing sessions after a password change according to the application’s policy. Verify that a reset writes the current format and does not disclose the new value through an email, log or support record. Our guide to account recovery journeys separates those decisions into a testable flow.

Keep rollback behavior in the deployment plan. If an older application version cannot read records created by the new version, returning to that version may break authentication even when the database migration appears reversible. Test the supported rollback combination before release, or document why the deployment must move forward instead. The decision should include background workers and regional instances that may run different versions during a rollout. A version identifier in the record is useful only when every active verifier handles it deliberately.

A release record should identify the library and configuration, the compatibility cases tested and the remaining legacy population. It should not promise that password hashing prevents every account compromise. The practical outcome is a maintained verification system whose behavior, cost and upgrade path are understood by the people responsible for operating it.