Questa pagina descrive come utilizzare la funzionalità di rilevamento delle fughe di password di reCAPTCHA per rilevare fughe di password e credenziali compromesse al fine di prevenire i takeover dell'account (ATO) e gli attacchi di credential stuffing. Con reCAPTHCA, puoi eseguire regolarmente controlli delle credenziali utente (password) nell'ambito di qualsiasi valutazione per assicurarti che non siano state divulgate o violate. Per eseguire queste valutazioni, Google utilizza la funzionalità Controllo password.
Prima di iniziare
Make sure that billing is enabled for your Google Cloud project.
Per utilizzare la funzionalità di rilevamento delle fughe di password, reCAPTCHA richiede che la fatturazione sia collegata e attivata nel progetto. Puoi attivare la fatturazione utilizzando una carta di credito o un ID fatturazione del progetto Google Cloud esistente. Se hai bisogno di assistenza per la fatturazione, contatta l'assistenza per la fatturazione Cloud.
Controlla le credenziali violate e divulgate
Puoi controllare se un set di credenziali è stato compromesso utilizzando con funzioni crittografiche o mediante il container Docker.
Il container Docker è un client open source che implementa computing multi-parti sicuro necessari per preservare la privacy dell'utente finale e cercare in sicurezza le fughe di password. Per maggiori informazioni, consulta il repository GitHub. Il container Docker astrae la complessità dell'implementazione algoritmi e semplifica il processo di installazione. Ti consente inoltre di ospitare un'app containerizzata nella tua infrastruttura.
Funzione di crittografia
Per verificare se un insieme di credenziali è stato compromesso, utilizza il rilevamento delle fughe di password quando crei valutazioni per azioni come accessi, modifiche e reimpostazione delle password.
Per verificare la presenza di fughe di password e credenziali compromesse:
- Generare i parametri della richiesta.
- Crea una valutazione per rilevare le fughe di password.
- Verifica le credenziali divulgate da una valutazione.
- Interpreta l'esito e intraprendi le azioni necessarie.
Genera i parametri di richiesta
- Calcola i parametri di richiesta necessari utilizzando le funzioni crittografiche richieste dal protocollo High Privacy. reCAPTCHA fornisce le librerie Java e TypeScript per aiutarti con generando questi campi:
Per creare verifiche di controllo delle password, crea un
PasswordCheckVerifier
.PasswordCheckVerifier verifier = new PasswordCheckVerifier();
Per avviare una verifica, chiama il numero
PasswordCheckVerifier#createVerification
. Questo metodo utilizza il nome utente e la password per calcolare i parametri per eseguire il controllo delle password.PasswordCheckVerification verification = verifier.createVerification("username", "password").get();
Crea una valutazione utilizzando i parametri di verifica.
byte[] lookupHashPrefix = verification.getLookupHashPrefix(); byte[] encryptedUserCredentialsHash = verification.getEncryptedUserCredentialsHash();
Gli array di byte
lookupHashPrefix
eencryptedUserCredentialsHash
contengono i parametri necessari per avviare un controllo delle passwordAssessment
.
Creare una valutazione per rilevare fughe di password
Utilizza la
projects.assessments.create
.
Prima di utilizzare i dati della richiesta, effettua le seguenti sostituzioni:
- PROJECT_ID: il tuo ID progetto Google Cloud
- LOOKUP_HASH_PREFIX: prefisso dell'hash SHA-256 del nome utente
- ENCRYPTED_USER_CREDENTIALS_HASH: hash Scrypt delle credenziali utente criptate
Metodo HTTP e URL:
POST https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments
Corpo JSON della richiesta:
{ "private_password_leak_verification": { "lookup_hash_prefix": "LOOKUP_HASH_PREFIX", "encrypted_user_credentials_hash": "ENCRYPTED_USER_CREDENTIALS_HASH" } }
Per inviare la richiesta, scegli una delle seguenti opzioni:
curl
Salva il corpo della richiesta in un file denominato request.json
,
quindi esegui il comando seguente:
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
Salva il corpo della richiesta in un file denominato request.json
,
quindi esegui il comando seguente:
$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
Dovresti ricevere una risposta JSON simile alla seguente:
{ "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="] } }
Verificare le credenziali trapelate da una valutazione
Estrai i campi reEncryptedUserCredentials
e encryptedLeakMatchPrefixes
dalla risposta della valutazione e passali all'oggetto verifier per determinare se le credenziali sono state divulgate o meno.
PasswordCheckResult result = verifier.verify(verification,
result.getReEncryptedUserCredentials(),
result.getEncryptedLeakMatchPrefixes()
).get();
System.out.println("Credentials leaked: " + result.areCredentialsLeaked());
Esempio di codice
I seguenti esempi di codice mostrano come implementare il rilevamento della divulgazione di password utilizzando le librerie Java e TypeScript:
Java
Per eseguire l'autenticazione in reCAPTCHA, configura le Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.
Node.js (TypeScript)
Per eseguire l'autenticazione a reCAPTCHA, configura le credenziali predefinite dell'applicazione. Per ulteriori informazioni, vedi Configura l'autenticazione per un ambiente di sviluppo locale.
Container Docker
Per controllare se le credenziali sono trapelate, invia in modo sicuro il nome utente e la coppia di credenziali della password al container utilizzando una connessione localhost o per configurare HTTPS sul container. Il contenitore cripta quindi queste credenziali prima di effettuare una richiesta API a reCAPTCHA e verifica il risultato nuovamente criptato localmente.
Per inviare richieste al container Docker, completa i seguenti passaggi:
- Configura Docker.
- Prepara un ambiente per il container Docker.
- Crea ed esegui il container.
- Invia richieste HTTP al container.
- Interpreta il verdetto e intervieni.
Preparati a eseguire il container Docker
Scegli una strategia di autenticazione.
Il contenitore supporta l'impostazione delle credenziali predefinite dell'applicazione o può accettare una chiave API per l'autenticazione.
Configura il container PLD in modo che venga eseguito con HTTPS o in una demo solo localhost .
Poiché il contenitore accetta credenziali utente sensibili (nomi utente e password), deve essere eseguito con HTTPS o in modalità demo solo localhost. Per indicazioni sulla configurazione HTTPS, consulta README su GitHub.
I passaggi che seguono utilizzano l'autenticazione con chiave API ed eseguono il client in modalità demo solo localhost.
Crea ed esegui il container Docker
Clona il repository:
git clone github.com/GoogleCloudPlatform/reCAPTCHA-PLD
Crea il container:
docker build . -t pld-local
Avvia il contenitore:
docker run --network host \ -e RECAPTCHA_PROJECT_ID=PROJECT_ID \ -e GOOGLE_CLOUD_API_KEY=API_KEY \ pld-local
Il contenitore si avvia e inizia a gestire le richieste sulla porta 8080 di localhost.
Inviare richieste a localhost
Prima di utilizzare i dati della richiesta, apporta le seguenti sostituzioni:
- LEAKED_USERNAME: nome utente della coppia di credenziali divulgate.
- LEAKED_PASSWORD: la password della coppia di credenziali divulgate.
Metodo HTTP e URL:
POST http://localhost:8080/createAssessment/
Corpo JSON della richiesta:
{ "username":"LEAKED_USERNAME", "password":"LEAKED_PASSWORD" }
Per inviare la richiesta, scegli una delle seguenti opzioni:
curl
Salva il corpo della richiesta in un file denominato request.json
,
quindi esegui il comando seguente:
curl -X POST \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"http://localhost:8080/createAssessment/"
PowerShell
Salva il corpo della richiesta in un file denominato request.json
,
quindi esegui il comando seguente:
$headers = @{ }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "http://localhost:8080/createAssessment/" | Select-Object -Expand Content
Dovresti ricevere una risposta JSON simile alla seguente:
{ "leakedStatus":"LEAKED" } OR { "leakedStatus":"NO_STATUS" }
Interpreta il verdetto e intraprendi azioni
La risposta della valutazione mostra se le credenziali sono trapelate e ti fornisce informazioni che puoi utilizzare per intraprendere azioni appropriate per proteggere i tuoi utenti.
Nella tabella seguente sono elencate le azioni consigliate che puoi intraprendere quando viene rilevata una password compromessa:
Password divulgata rilevata | Azioni per proteggere gli utenti |
---|---|
Durante l'accesso |
|
Durante la creazione dell'account o la reimpostazione della password |
|
Se non utilizzi già un provider di autenticazione a due fattori sul tuo sito, puoi utilizzare la funzionalità di autenticazione a due fattori di reCAPTCHA.
Passaggi successivi
- Scopri come utilizzare l'autenticazione a più fattori (MFA).
- Scopri come proteggere gli account utente utilizzando Account Defender reCAPTCHA di reCAPTCHA.