0Pricing
Secure Coding & OWASP Top 10 for Backend · Lección

Autenticación multifactor y recuperación de cuentas

Refuerce la autenticación más allá de las contraseñas con MFA y diseñe flujos seguros de recuperación de cuentas que no se conviertan en una puerta trasera para eludir sus protecciones.

Autenticación multifactor y recuperación de cuentas es una lección gratuita de Secure Coding & OWASP Top 10 for Backend en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Secure Coding & OWASP Top 10 for Backend, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Secure Coding & OWASP Top 10 for Backend incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en 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 consumed

Recovery 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 minutes

Avoid 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

Preguntas frecuentes

¿La lección «Autenticación multifactor y recuperación de cuentas» es gratis?

Sí — el texto completo de «Autenticación multifactor y recuperación de cuentas» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Secure Coding & OWASP Top 10 for Backend, actualiza a CoddyKit PRO. El curso de Secure Coding & OWASP Top 10 for Backend incluye 4 lecciones en total.

¿Qué aprenderé en «Autenticación multifactor y recuperación de cuentas»?

Refuerce la autenticación más allá de las contraseñas con MFA y diseñe flujos seguros de recuperación de cuentas que no se conviertan en una puerta trasera para eludir sus protecciones. Practicas Secure Coding & OWASP Top 10 for Backend con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Secure Coding & OWASP Top 10 for Backend?

No se requiere experiencia previa. Secure Coding & OWASP Top 10 for Backend en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Autenticación multifactor y recuperación de cuentas»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Secure Coding & OWASP Top 10 for Backend?

Sí. Cada lección de Secure Coding & OWASP Top 10 for Backend incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Implementación de un control de acceso sólido
  2. Mecanismos seguros de autenticación de usuarios
  3. Buenas prácticas de gestión de sesiones
  4. Autenticación multifactor y recuperación de cuentas
← Volver a Secure Coding & OWASP Top 10 for Backend