Autenticazione multifattore e recupero dell'account
Rafforzi l'autenticazione oltre le password con MFA e progetti flussi sicuri di recupero dell'account che non diventino una backdoor per aggirare le protezioni.
Autenticazione multifattore e recupero dell'account è una lezione Secure Coding & OWASP Top 10 for Backend gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Secure Coding & OWASP Top 10 for Backend, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Secure Coding & OWASP Top 10 for Backend include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Beyond the Password
Strong access control and good session management still rest on one assumption: the user is who they claim. Passwords alone are weak. Multi-factor authentication adds layers so a stolen password is not enough.
The Three Factors
Authentication factors fall into categories:
- Something you know — password, PIN
- Something you have — phone, hardware key
- Something you are — fingerprint, face
MFA combines two or more different categories.
TOTP Authenticator Apps
Time-based One-Time Passwords generate a 6-digit code from a shared secret and the current time. The server computes the same code to verify.
import pyotp
totp = pyotp.TOTP(user_secret)
is_valid = totp.verify(submitted_code)Why SMS Is Weaker
SMS codes are better than nothing but vulnerable to SIM swapping and interception. Prefer TOTP apps or hardware keys; reserve SMS as a last-resort option.
Hardware Keys and WebAuthn
WebAuthn uses public-key cryptography with a hardware or platform authenticator. There is no shared secret to phish — the strongest widely available MFA.
Backup Codes
What if a user loses their phone? Issue one-time backup codes at enrollment. Store them hashed, just like passwords, and invalidate each after use.
stored = hash(backup_code)
# on use: verify then mark consumedRecovery Is an Attack Surface
Account recovery often bypasses MFA. If recovery only needs an email link, an attacker who controls the inbox owns the account. Recovery must be as strong as login.
Secure Recovery Tokens
Recovery links should use a high-entropy, single-use, short-lived token, stored hashed and invalidated on use or password change.
token = secrets.token_urlsafe(32)
store(hash(token), expires_in=900) # 15 minutesAvoid Recovery Pitfalls
- Do not reveal whether an email exists (enumeration)
- Rate-limit recovery requests
- Notify the user when recovery is initiated
- Require re-enrollment of MFA after a full reset
Step-Up Authentication
For sensitive actions — changing email, large transfers — require a fresh factor even within an active session. This step-up limits the damage of a hijacked session.
Rate-Limiting the MFA Step
The MFA code entry is itself a target. A six-digit code has only a million possibilities, so without limits an attacker can brute-force it. Rate-limit and lock out after a few wrong codes, and expire each code quickly.
Quick Check
Test your MFA and recovery knowledge.
Recap
You strengthened authentication:
- MFA combines factors from different categories
- Prefer TOTP and WebAuthn over SMS
- Provide hashed backup codes
- Make recovery as strong as login with single-use, expiring tokens
- Use step-up auth for sensitive actions
Impara Secure Coding & OWASP Top 10 for Backend con un tutor IA — gratis
Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.
- Corsi
- 12
- Lezioni
- 48
Domande Frequenti
La lezione «Autenticazione multifattore e recupero dell'account» è gratuita?
Sì — il testo completo di «Autenticazione multifattore e recupero dell'account» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Secure Coding & OWASP Top 10 for Backend, passa a CoddyKit PRO. Il corso Secure Coding & OWASP Top 10 for Backend include 4 lezioni in totale.
Cosa imparerò in «Autenticazione multifattore e recupero dell'account»?
Rafforzi l'autenticazione oltre le password con MFA e progetti flussi sicuri di recupero dell'account che non diventino una backdoor per aggirare le protezioni. Eserciti Secure Coding & OWASP Top 10 for Backend con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Secure Coding & OWASP Top 10 for Backend?
Non è richiesta alcuna esperienza precedente. Secure Coding & OWASP Top 10 for Backend su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Autenticazione multifattore e recupero dell'account»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Secure Coding & OWASP Top 10 for Backend?
Sì. Ogni lezione Secure Coding & OWASP Top 10 for Backend include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Implementazione di un controllo degli accessi robusto
- Meccanismi sicuri di autenticazione degli utenti
- Best practice per la gestione delle sessioni
- Autenticazione multifattore e recupero dell'account