Azure AD and password synchronization

There is always a big discussion how safe it is to synchronize "password" to Microsoft cloud – Azure AD.

First of all, passwords are never synchronized to the cloud. Actually, the result of, 1000th iteration of the HMAS-SHA256 hashing function is being synchronized to the cloud. Microsoft is in this case also using per user salt when they are creating hash to be sent to the cloud. This means that even when two users are using same password, hash in the cloud would look different.

The whole process is described in this article and you can find the summery below:

  1. Every two minutes, the password hash synchronization agent on the AD Connect server requests stored password hashes (the unicodePwd attribute) from a DC. This request is via the standard MS-DRSR replication protocol used to synchronize data between DCs. The service account must have Replicate Directory Changes and Replicate Directory Changes All AD permissions (granted by default on installation) to obtain the password hashes.
  2. Before sending, the DC encrypts the MD4 password hash by using a key that is a MD5 hash of the RPC session key and a salt. It then sends the result to the password hash synchronization agent over RPC. The DC also passes the salt to the synchronization agent by using the DC replication protocol, so the agent will be able to decrypt the envelope.
  3. After the password hash synchronization agent has the encrypted envelope, it uses MD5CryptoServiceProvider and the salt to generate a key to decrypt the received data back to its original MD4 format. The password hash synchronization agent never has access to the clear text password. The password hash synchronization agent’s use of MD5 is strictly for replication protocol compatibility with the DC, and it is only used on premises between the DC and the password hash synchronization agent.
  4. The password hash synchronization agent expands the 16-byte binary password hash to 64 bytes by first converting the hash to a 32-byte hexadecimal string, then converting this string back into binary with UTF-16 encoding.
  5. The password hash synchronization agent adds a per user salt, consisting of a 10-byte length salt, to the 64-byte binary to further protect the original hash.
  6. The password hash synchronization agent then combines the MD4 hash plus the per user salt, and inputs it into the PBKDF2 1000 iterations of the HMAC-SHA256 keyed hashing algorithm are used.
  7. The password hash synchronization agent takes the resulting 32-byte hash, concatenates both the per user salt and the number of SHA256 iterations to it (for use by Azure AD), then transmits the string from Azure AD Connect to Azure AD over SSL.
  8. When a user attempts to sign in to Azure AD and enters their password, the password is run through the same MD4+salt+PBKDF2+HMAC-SHA256 process. If the resulting hash matches the hash stored in Azure AD, the user has entered the correct password and is authenticated.

Since hashes are different in Azure AD and in the on-premises environment they cannot be used for popular pass the hash attacks.

When hash of the password is synchronized to the cloud, users will always be able to authenticate to Office 365 resources even when your on-premises environment gets disconnected from the internet (regardless of the reason).

Comments are closed