What Type of Hash Does WordPress Use?
WordPress does not rely on a single, monolithic hashing algorithm for all its data. Instead, it employs a specific strategy known as bcrypt, but only when storing user password hashes in the database. The hash you providedâ$P$Bp.ZDNMM98mGNxCtHSkc1DqdRPXeoR.âis a definitive indicator of this choice.
The algorithm identifier $2y$ or $2a$ (common in older versions) has largely been replaced by $2b$, which is part of the modern bcrypt specification. The string structure reveals the underlying mechanics:
$2b$: Indicates the specific variant of bcrypt being used.- The following salt: A random value appended to ensure that identical passwords produce different hashes. WordPress generates a new, unique salt for every single user account. This is critical for security; without unique salts, an attacker could use pre-computed rainbow tables to crack multiple accounts simultaneously.
- The cost factor: Represented by the number following the salt (e.g.,
10in$2b$10$...). This dictates how computationally expensive it is to verify a password. A higher cost factor means more CPU cycles are required per check, slowing down brute-force attacks but increasing login latency. WordPress typically defaults this to 10 or slightly higher depending on the server's capabilities and version.
It is vital to distinguish between password hashing and other cryptographic operations within the ecosystem. While bcrypt handles passwords, WordPress uses MD5 for legacy reasons in specific contexts, such as generating hash-based signatures for post revisions or certain plugin integrations. However, relying on MD5 for security-sensitive data like passwords is a known vulnerability due to its speed and susceptibility to collision attacks. Modern WordPress versions have deprecated MD5 for password storage entirely in favor of bcrypt's adaptive difficulty.
When migrating a site or auditing existing code, you might encounter scenarios where the hash format has not been updated automatically. For instance, if a custom plugin manually inserts rows into the wp_users table, it might inadvertently use SHA-1 or an unhashed string. To rectify this without compromising user accounts, you must run a migration script that re-hashes existing passwords using the current bcrypt standard.
Here is a conceptual approach to ensuring your user data adheres to the modern standard:
// Example of verifying a password against a stored bcrypt hash
if (password_verify( $plain_password, $hashed_password_from_db ) === true) {
// Password matches; proceed with login logic
} else {
// Mismatch or invalid format
}
The password_verify() function is part of PHP's built-in password hashing library. It automatically detects the algorithm used in the stored hash (e.g., detecting $2b$ and treating it as bcrypt) and performs a constant-time comparison to prevent timing attacks. This abstraction layer allows you to change the underlying algorithm in future PHP versions without breaking authentication logic, provided you update your code generation scripts accordingly.
For developers using Laravel alongside WordPress projects, or when building custom authentication systems that need to interoperate with WordPress APIs, consistency is key. If you are building a separate application that needs to accept passwords from a WordPress user base, you must ensure you are validating against the $2b$ format specifically. Using Laravel's built-in hashing helper:
use Illuminate\Support\Facades\Hash;
// Store a password using the same logic WordPress uses
$hashed = Hash::make($password);
// Verify it later
if (Hash::check($password, $hashed)) {
// Success
}
However, note that while Laravel defaults to bcrypt, you can configure it to use argon2id if your server supports it. This is a superior algorithm in terms of memory hardness and resistance to GPU-based attacks. If you are architecting a system where WordPress is the identity provider, ensuring that any downstream services respect the bcrypt cost factor is essential. Reducing the cost factor to speed up logins invites brute-force vulnerabilities; increasing it too high degrades user experience. The sweet spot usually lies between 10 and 12, depending on whether you prioritize defense-in-depth or sub-second response times.
Ultimately, understanding that WordPress uses bcrypt allows you to audit your database directly. Look for the $2b$ prefix in the password column of the wp_users table. If you see anything resembling MD5 (e10adc3949ba59abbe56e057f20f883e) or unhashed plaintext, your site is at immediate risk and requires urgent remediation.
