Apple detects a compromised password by matching it up with a list of passwords that have appeared in a data leak. According to Apple, this feature uses strong cryptographic techniques to regularly check derivations of your passwords against a list of breached passwords in a secure and private way that doesn't reveal your accounts or passwords to Apple.