Autenticação multifator e recuperação de contas
Fortaleça a autenticação para além das senhas com MFA e projete fluxos seguros de recuperação de contas que não se tornem uma porta dos fundos para contornar suas proteções.
Autenticação multifator e recuperação de contas é uma aula grátis de Secure Coding & OWASP Top 10 for Backend no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Secure Coding & OWASP Top 10 for Backend, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Secure Coding & OWASP Top 10 for Backend inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
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
Perguntas Frequentes
A aula “Autenticação multifator e recuperação de contas” é grátis?
Sim — o texto completo de “Autenticação multifator e recuperação de contas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Secure Coding & OWASP Top 10 for Backend, atualize para CoddyKit PRO. O curso de Secure Coding & OWASP Top 10 for Backend inclui 4 aulas no total.
O que vou aprender em “Autenticação multifator e recuperação de contas”?
Fortaleça a autenticação para além das senhas com MFA e projete fluxos seguros de recuperação de contas que não se tornem uma porta dos fundos para contornar suas proteções. Você pratica Secure Coding & OWASP Top 10 for Backend com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Secure Coding & OWASP Top 10 for Backend?
Nenhuma experiência prévia é necessária. Secure Coding & OWASP Top 10 for Backend no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.
Quanto tempo leva a aula “Autenticação multifator e recuperação de contas”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Secure Coding & OWASP Top 10 for Backend?
Sim. Cada aula de Secure Coding & OWASP Top 10 for Backend inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Implementação de um controle de acesso robusto
- Mecanismos seguros de autenticação de usuários
- Práticas recomendadas de gerenciamento de sessões
- Autenticação multifator e recuperação de contas