Cette page explique comment utiliser la fonctionnalité de détection des fuites de mots de passe de reCAPTCHA Enterprise pour détecter les fuites de mots de passe et les identifiants piratés afin d'empêcher les piratages de compte et les attaques par credential stuffing. Avec reCAPTCHA Enterprise, vous pouvez effectuer des audits réguliers des identifiants (mots de passe) des utilisateurs lors de toute évaluation pour vous assurer qu'ils n'ont pas été divulgués ou compromis. Pour effectuer ces évaluations, Google utilise la fonctionnalité Check-up Mots de passe.
Avant de commencer
Vérifiez que la facturation est activée pour votre projet Google Cloud.
reCAPTCHA Enterprise exige que la facturation soit associée et activée sur le projet pour que vous puissiez utiliser la fonctionnalité de détection des fuites de mots de passe. Vous pouvez activer la facturation à l'aide d'une carte de crédit ou d'un n° compte facturation existant pour un projet Google Cloud. Si vous avez besoin d'aide avec la facturation, contactez l'assistance Cloud Billing.
Rechercher les identifiants piratés ou divulgués
Pour vérifier si un ensemble d'identifiants a été compromis, utilisez la détection des fuites de mots de passe lorsque vous créez des évaluations pour des actions telles que les connexions, les changements de mots de passe et les réinitialisations.
Pour rechercher des fuites de mots de passe et des identifiants piratés, procédez comme suit:
- Générez des paramètres de requête.
- Créez une évaluation pour détecter les fuites de mots de passe.
- Vérifiez les identifiants divulgués lors d'une évaluation.
- Interpréter le verdict et prendre des mesures
Générer des paramètres de requête
Calculez les paramètres de requête nécessaires à l'aide des fonctions cryptographiques requises par le protocole à confidentialité élevée. reCAPTCHA Enterprise fournit des bibliothèques Java et TypeScript pour vous aider à générer ces champs:
Pour créer des vérifications de mot de passe, créez un objet
PasswordCheckVerifier
.PasswordCheckVerifier verifier = new PasswordCheckVerifier();
Pour lancer une validation, appelez
PasswordCheckVerifier#createVerification
. Cette méthode utilise le nom d'utilisateur et le mot de passe pour calculer les paramètres permettant de vérifier le mot de passe.PasswordCheckVerification verification = verifier.createVerification("username", "password").get();
Créez une évaluation à l'aide des paramètres de validation.
byte[] lookupHashPrefix = verification.getLookupHashPrefix(); byte[] encryptedUserCredentialsHash = verification.getEncryptedUserCredentialsHash();
Les tableaux d'octets
lookupHashPrefix
etencryptedUserCredentialsHash
contiennent les paramètres requis pour lancer une vérification de mot de passeAssessment
.
Créer une évaluation pour détecter les fuites de mots de passe
Exécutez la méthode projects.assessments.create
.
Avant d'utiliser les données de requête, effectuez les remplacements suivants:
- PROJECT_ID : ID de votre projet Google Cloud
- LOOKUP_HASH_PREFIX: préfixe du préfixe de hachage SHA-256 du nom d'utilisateur
- ENCRYPTED_USER_CREDENTIALS_HASH: hachage Scrypt des identifiants utilisateur chiffrés
Méthode HTTP et URL :
POST https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments
Corps JSON de la requête :
{ "private_password_leak_verification": { "lookup_hash_prefix": "LOOKUP_HASH_PREFIX", "encrypted_user_credentials_hash": "ENCRYPTED_USER_CREDENTIALS_HASH" } }
Pour envoyer votre requête, choisissez l'une des options suivantes :
curl
Enregistrez le corps de la requête dans un fichier nommé request.json
et exécutez la commande suivante:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments"
PowerShell
Enregistrez le corps de la requête dans un fichier nommé request.json
et exécutez la commande suivante:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments" | Select-Object -Expand Content
Vous devriez recevoir une réponse JSON de ce type :
{ "name": "projects/698047609967/assessments/fb22000000000000", "score": 0, "reasons": [], "privatePasswordLeakVerification": { "lookupHashPrefix": "zoxZwA==", "encryptedUserCredentialsHash": "AyRihRcKaGLj/FA/r2uqQY/fzfTaDb/nEcIUMeD3Tygp", "reencryptedUserCredentialsHash": "Aw65yEbLM39ww1ridDEfx5VhkWo11tzn/R1B88Qqwr/+" "encryptedLeakMatchPrefixes": [ "n/n5fvPD6rmQPFyb4xk=", "IVQqzXsbZenaibID6OI=", ..., "INeMMndrfnlf6osCVvs=", "MkIpxt2x4mtyBnRODu0=", "AqUyAUWzi+v7Kx03e6o="] } }
Vérifier les identifiants piratés lors d'une évaluation
À partir de la réponse d'évaluation, extrayez les champs reEncryptedUserCredentials
et encryptedLeakMatchPrefixes
, puis transmettez-les à l'objet de vérification pour déterminer si les identifiants ont été divulgués ou non.
PasswordCheckResult result = verifier.verify(verification,
result.getReEncryptedUserCredentials(),
result.getEncryptedLeakMatchPrefixes()
).get();
System.out.println("Credentials leaked: " + result.areCredentialsLeaked());
Interpréter le verdict et prendre des mesures
La réponse d'évaluation indique si les identifiants ont été divulgués et vous fournit des informations que vous pouvez utiliser pour prendre les mesures appropriées pour protéger vos utilisateurs.
Le tableau suivant répertorie les actions recommandées que vous pouvez effectuer en cas de fuite de mot de passe:
Mot de passe volé détecté | Actions de protection de l'utilisateur |
---|---|
Lors de la connexion |
|
Lors de la création du compte ou de la réinitialisation du mot de passe |
|
Si vous n'utilisez pas encore de fournisseur MFA sur votre site, vous pouvez utiliser la fonctionnalité MFA de reCAPTCHA Enterprise.
Exemple de code
Java
Pour vous authentifier auprès de reCAPTCHA Enterprise, configurez les Identifiants par défaut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de développement local.
Node.js (TypeScript)
Pour vous authentifier auprès de reCAPTCHA Enterprise, configurez les Identifiants par défaut de l'application. Pour en savoir plus, consultez Configurer l'authentification pour un environnement de développement local.
Étapes suivantes
- Découvrez comment utiliser l'authentification multifacteur (MFA).
- Découvrez comment protéger les comptes utilisateur à l'aide de reCAPTCHA Enterprise Account Defender.