Drupal's Default Password Hashing Strategy in Versions 6 and 7
Drupal 6 and Drupal 7 do not rely on modern algorithms like bcrypt or Argon2 by default. Instead, they utilize the MD5 hashing algorithm combined with a random salt to store user passwords. This specific implementation is defined by the sha512_crypt function in later versions of Drupal, but for the older 6.x and 7.x branches, the core behavior defaults to MD5 unless explicitly configured otherwise via the database schema or custom modules.
The storage format you will encounter in the users table is a long hexadecimal string. In Drupal 7, this string typically consists of 40 characters representing the MD5 hash concatenated with a 16-byte salt encoded as a hex string (adding another 32 characters), resulting in a total length of around 88 characters depending on the specific implementation details found in the database dump. The actual algorithm executed during registration is often md5() wrapped with a salt derived from drupal_random_bytes().
This approach was standard practice when these versions were current, but it presents significant security liabilities today. MD5 is computationally cheap and susceptible to rainbow table attacks if salts are not properly managed. While Drupal 7 does introduce the concept of algorithmic hashing through its phpass support in later patches or specific distributions, the out-of-the-box installation defaults to a simpler hash function that lacks the iterative cost factors found in modern standards.
To verify what is actually stored, you can query your database directly. Look at the users table and inspect the pass column. If you see a string starting with $S$ followed by numbers, Drupal is using its custom salted hash format which wraps MD5. If you are upgrading from a legacy system or migrating data, identifying this hash type is critical before attempting to reset passwords via command line tools like drush or manual SQL scripts.
The trade-off here lies in performance versus security. Using MD5 allows for extremely fast verification times, which might seem beneficial for high-traffic sites with thousands of concurrent logins. However, speed is the enemy of password security. Attackers do not need to guess a single password; they can generate billions of hashes per second using specialized hardware (GPUs or ASICs). Because MD5 lacks a configurable work factorâmeaning you cannot force it to take longer to compute by increasing iterationsâit offers no defense against brute-force attempts once the salt is known.
When upgrading from Drupal 6 or 7 to modern versions like Drupal 9 or 10, this legacy hashing method is deprecated. Modern Drupal core defaults to bcrypt, which allows administrators to adjust the cost factor (e.g., CRYPT_BLOWFISH with a specific complexity setting) to balance security and performance. If you are maintaining a legacy Drupal 7 site for a long time, it is highly recommended to install the Password Hashing module or similar patches that force the system to use stronger algorithms like PBKDF2 or bcrypt immediately.
For developers working with Laravel projects who need to handle legacy migrations, understanding these differences is essential. You might find resources discussing modern migration strategies at https://laravelcompany.com to see how they approach data integrity and security upgrades in similar contexts. The principle remains the same: never migrate sensitive user data into a system that relies on broken primitives like MD5 without actively remapping the hashes during the transition.
The code responsible for this hashing resides in the user_register() or auth.api_user_create() functions, where the salt is generated and appended to the raw password before being passed to the hash function. If you are auditing an existing Drupal 7 installation, checking the $settings['hash'] configuration or the database schema can reveal if a custom algorithm has been applied previously. However, relying on default configurations in these older versions means assuming MD5 until proven otherwise.
Ultimately, the decision to stick with MD5 was driven by hardware limitations and cryptographic standards of the mid-2000s. Today, the computational cost of cracking an MD5 hash is negligible compared to the risk it poses. If you are still running Drupal 6 or 7 in production, treating user passwords as compromised is often the most pragmatic security decision until a migration path is executed.