Password Migration: Moving User Passwords to a New System Without Forcing Everyone to Reset

Solution Architect

4 Dec 20267 min read

Password Migration: Moving User Passwords to a New System Without Forcing Everyone to Reset

A mass reset looks like phishing and costs customers. How a careful password migration carries hashes across, upgrades weak ones at sign-in, retires the rest.

Every account in your Legacy PHP application has a password, and when you move to a new system, every one of those passwords has to keep working. Password migration is where customer experience and security risk meet: get it wrong and you either lock customers out on switch-over day or carry an old weakness, one that could expose every account if the user table leaks, into the new platform.

The tempting shortcut is to email every user and ask them to set a new password. It feels clean, but it is one of the most disruptive things a migration can do to your customers. There is usually a better path, and it starts with what your old system actually stored.

The decision you're facing

A well-built application never stores the password itself. It stores a hash: the result of running the password through a one-way scrambling function. When you sign in, the system scrambles what you typed the same way and checks whether the two results match. The OWASP Password Storage Cheat Sheet explains why this is the right approach: because hashing is one-way, "it is impossible to 'decrypt' a hash and obtain the original plaintext value".

That has a direct consequence for migration:** you can't move the passwords, only the hashes**. So the new system has to be able to check the old hashes, or the old hashes have to be replaced.

What you have depends on the application's age.

  • Modern PHP password functions. Since PHP 5.5, PHP has offered a built-in password function whose default, according to the PHP manual, is the bcrypt algorithm. The manual notes that each stored result contains "the used algorithm, cost and salt", so "all information that's needed to verify the hash is included in it". bcrypt is a widely used standard, not a PHP invention, so these hashes are good candidates to carry across.
  • Older, fast hashes. Many older applications stored passwords as plain MD5 or SHA-1 hashes, often without a salt (a random value added to each password so that two users with the same password get different hashes). OWASP names MD5 and SHA-1 as the "less secure hashing algorithms" of older applications. They are fast, and speed helps attackers: OWASP notes that with graphics hardware and rented cloud servers, the cost of cracking is "relatively small", especially "when best practices for hashing are not followed".
  • Something unusual. Home-grown schemes, a framework's own format or, worst of all, passwords stored in a reversible form.

Most organisations then choose between three options: force everyone to reset, carry the hashes across, or upgrade each hash when its owner next signs in.

What goes wrong when it's done carelessly

These are realistic risks, not documented incidents.

  • The mass reset backfires. A sudden "please reset your password" email to every customer looks a lot like phishing, and real phishers can copy it. Some users ignore it and some simply leave. OWASP makes a similar point about expiring passwords in bulk: it "may cause issues for support staff or may be interpreted by users as an indication of a breach".
  • A reset is used where none is needed. NIST's current guideline, SP 800-63B-4 (finalised July 2025), says systems "SHALL NOT require subscribers to change passwords periodically", but "SHALL force a change if there is evidence that the authenticator has been compromised". A migration on its own is not evidence of compromise.
  • Weak hashes travel unchanged into the new system. Unsalted MD5 hashes copied across "for now" give the new platform the old one's weakness, and "for now" tends to become permanent.
  • The format is subtly mismatched. Two systems may both "support bcrypt" and still disagree on details. PHP's manual says its bcrypt hashes carry a "2y" label. The README of the node.bcrypt.js library says it supports the "2a" and "2b" labels and that "2y" hashes "in theory" should be compatible. "In theory" is not a test result.
  • The old hashes never leave. A copy of the old user table on a forgotten server or backup keeps weak hashes alive long after go-live.

The defensive approach to password migration

At the level of concepts, a safe password migration has four parts.

1. Find out exactly what you have. Look at the stored hashes themselves, not the documentation. Count how many accounts use each format and how many are active. Two or three formats in one table is common.

2. Carry over what the new system can verify. If your PHP application uses the built-in password functions, the new system can usually check the same bcrypt hashes directly, so users notice nothing. Prove that with real samples before the switch, including passwords with accented or non-Latin characters. OWASP also notes that bcrypt only reads the first 72 bytes of a password in most implementations, so very long passwords deserve a specific check.

3. Upgrade each user's hash when they next sign in. At sign-in, the system briefly has the real password in hand. OWASP describes using that moment: when users enter their password, "that input should be re-hashed using the new algorithm". The user notices nothing. For the most current choice of algorithm, OWASP recommends Argon2id, with bcrypt as an option for legacy systems.

4. Protect the accounts that don't sign in, then retire the old hashes. The weakness of upgrade-on-sign-in is that a weak hash stays in the database until its owner returns, and some never will. OWASP offers two ways out. One is to wrap the old hash inside a stronger one straight away, so nothing is stored in the weak form, and replace it with a direct hash at the next sign-in. OWASP adds that this layering "can make the hashes easier to crack" than a direct modern hash, so it's a bridge, not a destination. The other is to expire the hashes of users inactive for an extended period and ask only those users to reset when they return. Set a date for each step, and include backups and copies in the clean-up.

The point of this approach is that a reset becomes the exception, for dormant accounts and for any account with real evidence of compromise, rather than the plan.

Where Node.js fits, and where it doesn't

Node.js has libraries for bcrypt and Argon2id, so a Node.js system can verify carried-over bcrypt hashes and create modern ones for new and upgraded accounts. Depending on the application, that makes it a reasonable home for sign-in once it moves.

But the language doesn't do the work. Choosing the algorithm and its settings, handling old formats, testing compatibility and deleting weak hashes are decisions your team still has to own. A new Node.js system with weak password storage is no safer than the PHP system it replaced.

Two related decisions sit nearby: keeping users signed in while both systems run, and whether to adopt multi-factor authentication or a standard identity service. Neither replaces storing passwords properly in the meantime.

What this means for your organisation

Ask these questions of your own system:

  • Which password formats are actually in your user table today, and how many accounts use each?
  • Are any passwords stored unsalted, with a fast algorithm, or in a form that can be reversed?
  • Has anyone tested whether the new system can verify your existing hashes, using real samples rather than assumptions?
  • How many accounts are dormant, and what will happen to them?
  • Where else do copies of the user table live: backups, reporting databases, old servers, developer laptops?
  • Who decides when the last weak hash is deleted, and how will you prove it's gone?

Recommended next step

Before planning any user communication, take an inventory of your stored passwords: which formats exist, how many accounts use each, how many are active, and every place a copy of that data is held. That inventory tells you whether you can avoid a mass reset, which accounts need an upgrade path, and how long old hashes must be protected before deletion. Our Free Security and Modernisation Review is a practical place to begin: it looks at where your current application is exposed, including how it stores credentials, and the safest route to a secure, modern platform.

Free Security and Modernisation Review

Sketchmonk is a security-led software engineering company. Our engineers have built software for a national defence research lab, global cyber security vendors and security-first product companies, with 16+ years of engineering behind them. In a free Security and Modernisation Review, we look at the application you run today: where it is exposed, what it depends on, and the safest route to a secure, modern platform. Want to see how we have handled problems like yours? Ask for a case study in the same email. There's no obligation to proceed.

Request your free Security and Modernisation Review

Build with us. Deploy with us. Win with us

We don't deliver projects and walk away. We build with you, inside your mission.

Book a strategic consultation