En esta página, se describe cómo usar la función de detección de filtración de contraseñas de reCAPTCHA Enterprise para detectar filtraciones de contraseñas y credenciales vulneradas con el objetivo de evitar la apropiación de cuentas (ATO) y los ataques de uso excesivo de credenciales. Con reCAPTCHA Enterprise, puedes realizar auditorías regulares de las credenciales de los usuarios (contraseñas) como parte de cualquier evaluación para asegurarte de que no se hayan filtrado ni vulnerado. Para realizar estas evaluaciones, Google usa la función de Revisión de contraseñas.
Antes de comenzar
Asegúrate de que la facturación esté habilitada para tu proyecto de Google Cloud.
reCAPTCHA Enterprise requiere que la facturación esté vinculada y habilitada en el proyecto para usar la función de detección de filtración de contraseñas. Puedes habilitar la facturación con una tarjeta de crédito o un ID de facturación de un proyecto de Google Cloud existente. Si necesitas ayuda con la facturación, comunícate con el equipo de asistencia de Facturación de Cloud.
Verifica si hay credenciales filtradas y filtradas
Para comprobar si se vulneró un conjunto de credenciales, usa la detección de filtración de contraseñas cuando crees evaluaciones de acciones como accesos, cambios de contraseñas y restablecimientos de contraseñas.
Para comprobar si hay filtraciones de contraseñas y credenciales violadas, completa los siguientes pasos:
- Genera parámetros de solicitud.
- Crea una evaluación para detectar filtraciones de contraseñas.
- Verifica las credenciales filtradas en una evaluación.
- Interpreta el veredicto y toma medidas.
Genera parámetros de solicitud
Calcula los parámetros de solicitud necesarios con las funciones criptográficas que requiere el protocolo de alta privacidad. reCAPTCHA Enterprise proporciona bibliotecas de Java y TypeScript para ayudar a generar estos campos:
Para generar verificaciones de verificación de contraseñas, crea un objeto
PasswordCheckVerifier
.PasswordCheckVerifier verifier = new PasswordCheckVerifier();
Para iniciar una verificación, llama a
PasswordCheckVerifier#createVerification
. Este método usa el nombre de usuario y la contraseña para calcular los parámetros a fin de realizar la verificación de la contraseña.PasswordCheckVerification verification = verifier.createVerification("username", "password").get();
Crea una evaluación con los parámetros de verificación.
byte[] lookupHashPrefix = verification.getLookupHashPrefix(); byte[] encryptedUserCredentialsHash = verification.getEncryptedUserCredentialsHash();
Los arrays de bytes
lookupHashPrefix
yencryptedUserCredentialsHash
contienen los parámetros necesarios para iniciar una verificación de contraseñaAssessment
.
Crear una evaluación para detectar filtraciones de contraseñas
Usa el método projects.assessments.create
.
Antes de usar cualquiera de los datos de solicitud a continuación, realiza los siguientes reemplazos:
- PROJECT_ID: El ID del proyecto de Google Cloud.
- LOOKUP_HASH_PREFIX: Prefijo del nombre de usuario SHA-256 del prefijo de hash
- ENCRYPTED_USER_CREDENTIALS_HASH: Hash de Scrypt de credenciales de usuario encriptadas
HTTP method and URL:
POST https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments
Cuerpo JSON de la solicitud:
{ "private_password_leak_verification": { "lookup_hash_prefix": "LOOKUP_HASH_PREFIX", "encrypted_user_credentials_hash": "ENCRYPTED_USER_CREDENTIALS_HASH" } }
Para enviar tu solicitud, elige una de estas opciones:
curl
Guarda el cuerpo de la solicitud en un archivo llamado request.json
y ejecuta el siguiente comando:
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
Guarda el cuerpo de la solicitud en un archivo llamado request.json
y ejecuta el siguiente comando:
$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
Deberías recibir una respuesta JSON similar a la que se muestra a continuación:
{ "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="] } }
Verificar las credenciales filtradas desde una evaluación
De la respuesta de la evaluación, extrae los campos
reEncryptedUserCredentials
y encryptedLeakMatchPrefixes
, y pásalos al
objeto verificador para determinar si las credenciales se filtraron o no.
PasswordCheckResult result = verifier.verify(verification,
result.getReEncryptedUserCredentials(),
result.getEncryptedLeakMatchPrefixes()
).get();
System.out.println("Credentials leaked: " + result.areCredentialsLeaked());
Interpreta el veredicto y toma medidas
La respuesta de la evaluación muestra si se filtraron las credenciales y te proporciona información que puedes usar para tomar las medidas adecuadas y proteger a tus usuarios.
En la siguiente tabla, se enumeran las acciones recomendadas que puedes realizar cuando se detecta una contraseña filtrada:
Se detectó una contraseña filtrada | Acciones para proteger al usuario |
---|---|
Durante el acceso |
|
Durante la creación de la cuenta o el restablecimiento de la contraseña |
|
Si todavía no utilizas un proveedor de MFA en tu sitio, puedes usar la función de MFA de reCAPTCHA Enterprise.
Muestra de código
Java
Para autenticarte en reCAPTCHA Enterprise, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.
Node.js (TypeScript)
Para autenticarte en reCAPTCHA Enterprise, configura las credenciales predeterminadas de la aplicación. Si deseas obtener más información, consulta Configura la autenticación para un entorno de desarrollo local.
¿Qué sigue?
- Obtén información para usar la autenticación de varios factores (MFA).
- Obtén información para proteger las cuentas de los usuarios con Account Defender de reCAPTCHA Enterprise.