Authentication & Access Control
Identification vs authentication vs authorization, JWT structure and pitfalls, defending auth flows, account recovery and OTP abuse.
20 questions
JuniorTheoryVery commonWhat is the difference between identification, authentication, and authorization?
What is the difference between identification, authentication, and authorization?
Identification claims who you are (a username). Authentication proves that claim (password, token, biometric). Authorization decides what that identity may do (roles, permissions). They run in that order: identify, authenticate, authorize each action.
Common mistakes
- ✗Confusing authentication (proving identity) with authorization (access rights)
- ✗Treating identification and authentication as a single step
- ✗Thinking authorization can precede authentication
Follow-up questions
- →Which of the three steps does multi-factor authentication (MFA) belong to?
- →Why is authorization checked on every request rather than once at login?
JuniorTheoryVery commonWhat three parts make up a JWT and how is it protected?
What three parts make up a JWT and how is it protected?
A JWT is three dot-joined base64url parts — header.payload.signature. The header names the algorithm, the payload holds claims, the signature covers both. A standard JWT is signed, not encrypted: the payload is readable, only tampering is visible.
Common mistakes
- ✗Assuming the JWT is encrypted and the payload is hidden from the client
- ✗Putting sensitive data in the payload, assuming it is private
- ✗Confusing signing (integrity) with encryption (confidentiality)
Follow-up questions
- →Why must secrets not be stored in the payload of a standard JWT?
- →How does a signed JWT differ from an encrypted one (JWE)?
JuniorTheoryVery commonWhich multi-factor authentication factors exist and why is SMS the weakest?
Which multi-factor authentication factors exist and why is SMS the weakest?
Factors are what you know, what you have and what you are. SMS is weakest — codes cross a carrier network you do not control and fall to SIM swap. A one-time password is phishable in real time; only WebAuthn binds to the site origin.
Common mistakes
- ✗Treating every second factor as equally strong
- ✗Believing a longer SMS code fixes SIM swap and interception
- ✗Missing that only origin binding makes a factor phishing-resistant
Follow-up questions
- →How does a real-time phishing proxy defeat a time-based one-time password?
- →What does the authentication standard
WebAuthnbind a credential to?
MiddleDesignVery commonDesign defenses for a login system against credential-guessing attacks. What detection and prevention mechanisms are needed against credential stuffing (trying leaked login-password pairs), password spraying (one password across many logins), brute-force, user enumeration (login enumeration), and session fixation and hijacking? Describe what to detect, how to respond, and what to prevent at the design level.
Design defenses for a login system against credential-guessing attacks. What detection and prevention mechanisms are needed against credential stuffing (trying leaked login-password pairs), password spraying (one password across many logins), brute-force, user enumeration (login enumeration), and session fixation and hijacking? Describe what to detect, how to respond, and what to prevent at the design level.
Detect failed-login spikes per account (brute-force) or across accounts (stuffing/spraying). Prevent via throttling, CAPTCHA, dictionary blocking, and MFA. Identical error responses block enumeration; rotate session tokens at login; SameSite + httpOnly cookies.
Common mistakes
- ✗Detecting only by volume, missing per-account and per-password metrics
- ✗Returning different responses for 'no such user' and 'wrong password' (enumeration)
- ✗Reusing the pre-login session token after login (session fixation)
Follow-up questions
- →How does the password spraying signature differ from brute-force in the login logs?
- →Why does rotating the session token at login close off session fixation?
JuniorTheoryCommonWhat is a passkey, and which password risks does it remove outright?
What is a passkey, and which password risks does it remove outright?
A passkey is a public-key credential from WebAuthn. The private key stays on the device and only the public key reaches the server, so there is no shared secret to leak or replay. The browser signs only for the registered origin.
Common mistakes
- ✗Thinking a passkey is a password the browser stores and sends
- ✗Assuming the server holds a secret that a breach dump could expose
- ✗Missing that the signature is bound to the registered origin
Follow-up questions
- →How does a device-bound passkey differ from a synced one in recovery risk?
- →Why does a server breach not compromise accounts protected by passkeys?
JuniorTheoryCommonWhich password policy actually helps: length, breach checks, or rotation?
Which password policy actually helps: length, breach checks, or rotation?
The standards body NIST favours a long minimum, a generous maximum, and screening new passwords against breach lists. Composition rules and calendar rotation are discouraged — they drive predictable mutations. Rotate on evidence of compromise.
Common mistakes
- ✗Forcing a password change every ninety days without any compromise signal
- ✗Requiring character classes instead of length and breach screening
- ✗Capping password length so passphrases and managers no longer fit
Follow-up questions
- →Why does calendar rotation produce predictable password mutations?
- →Which signals should actually trigger a forced reset for an account?
JuniorTheoryCommonHow do access-control models RBAC and ABAC differ, and when does each fit?
How do access-control models RBAC and ABAC differ, and when does each fit?
Role-based access control grants permissions through named roles — easy to audit, but roles multiply as exceptions appear. Attribute-based access control decides per request from user, resource, action and context. Both must default to deny.
Common mistakes
- ✗Treating ABAC as strictly superior instead of costlier to reason about
- ✗Assuming a default-allow policy is acceptable if roles are correct
- ✗Adding a new role for every exception until roles outnumber users
Follow-up questions
- →What is role explosion, and which signal shows it is already happening?
- →Why must an access decision default to deny when no policy matches?
JuniorTheoryCommonWhat is the difference between a salt and a pepper in password hashing?
What is the difference between a salt and a pepper in password hashing?
A salt is a unique random value stored with the hash, so identical passwords hash differently and rainbow tables fail. A pepper is a secret kept outside the database, so a stolen dump resists it. Both back a slow KDF like Argon2id.
Common mistakes
- ✗Treating the salt as a secret that must be hidden from the database
- ✗Assuming a salt or pepper makes a fast hash like SHA-256 acceptable
- ✗Reusing one shared salt value for every user in the table
Follow-up questions
- →Why must a salt be unique per user rather than per application?
- →Where should a pepper live so a database dump never exposes it?
JuniorTheoryCommonWhat makes a session identifier safe, and which cookie attributes protect it?
What makes a session identifier safe, and which cookie attributes protect it?
A session id must be long and drawn from a cryptographic random source, never derived from a username or counter, and reissued at login. Send it in a cookie marked Secure, HttpOnly and SameSite so scripts and other sites cannot use it.
Common mistakes
- ✗Deriving the session id from a user id, email, or counter
- ✗Keeping the pre-login session id after successful authentication
- ✗Omitting
HttpOnlyorSameSiteon the session cookie
Follow-up questions
- →Why must the session identifier be reissued at login?
- →What does the cookie attribute
SameSiteprevent thatHttpOnlydoes not?
MiddleTheoryCommonWhat common vulnerabilities arise with JWT-based authentication?
What common vulnerabilities arise with JWT-based authentication?
Key risks — alg=none accepted, HS/RS algorithm confusion, weak HMAC secrets, missing or unbounded exp, sensitive data in the readable payload, and an unvalidated kid header. Fix by pinning the algorithm, validating exp, and using strong keys.
Common mistakes
- ✗Not rejecting
alg=nonetokens on the server side - ✗Storing sensitive data in the payload, assuming it is hidden
- ✗Issuing tokens without a bounded expiry (
exp)
Follow-up questions
- →How does the HS256/RS256 algorithm confusion attack work?
- →Why validate the
kidheader before loading a key?
MiddleTheoryCommonWhere on the client should a JWT be stored, and what are the risks of each option?
Where on the client should a JWT be stored, and what are the risks of each option?
Store the JWT in an httpOnly + secure cookie or in memory — not in localStorage, which any JavaScript reads, so one XSS steals the token. An httpOnly cookie is invisible to JS but sent automatically, so it needs CSRF protection (SameSite). Note: httpOnly/secure are cookie attributes, not applicable to localStorage.
Common mistakes
- ✗Believing httpOnly/secure apply to localStorage
- ✗Storing the JWT in localStorage, underestimating the theft risk via XSS
- ✗Confusing a signed JWT with an encrypted one (the payload is readable)
Follow-up questions
- →Why does storing a JWT in an httpOnly cookie also require CSRF protection?
- →How is storing the token in memory safer than localStorage, and what is its downside?
MiddleDesignCommonYou are auditing password recovery: enter email → link /restore/<id> → enter OTP → new password. What do you check? A link like /restore/1678371465 contains a timestamp. List the flaws and controls at each step — from email handling to OTP verification and the password change.
You are auditing password recovery: enter email → link /restore/<id> → enter OTP → new password. What do you check? A link like /restore/1678371465 contains a timestamp. List the flaws and controls at each step — from email handling to OTP verification and the password change.
A timestamp /restore/<id> is predictable — use an unguessable random token, single-use, short TTL. Identical responses block enumeration; build the URL from config, not the Host header. Rate-limit OTP sends and wrong entries, set a TTL, cap retries.
Common mistakes
- ✗Using a predictable link identifier (timestamp/counter)
- ✗Building the recovery URL from the Host header (host header injection)
- ✗Not capping OTP entry attempts and not setting its TTL
Follow-up questions
- →Why must the recovery link not be built from the Host header?
- →What race condition is possible at the OTP verification step?
MiddleTheoryCommonWhy is account lockout a poor answer to credential stuffing, and what replaces it?
Why is account lockout a poor answer to credential stuffing, and what replaces it?
Stuffing replays breached pairs one try per account, so per-account counters barely fire. Hard lockout then becomes a weapon — an attacker locks real users out on purpose. Prefer graduated throttling, device and network signals, and risk-based MFA.
Common mistakes
- ✗Detecting only per-account failures, which stuffing deliberately avoids
- ✗Treating lockout as free, ignoring the denial of service it hands an attacker
- ✗Blocking single addresses against a campaign spread over many hosts
Follow-up questions
- →Which metric separates stuffing from a brute-force run against one account?
- →How does graduated throttling stay usable for a legitimate user who mistypes?
JuniorDesignOccasionalHow do you reduce the damage from a spam attack on SMS code sending (SMS bombing)?
How do you reduce the damage from a spam attack on SMS code sending (SMS bombing)?
Each SMS costs money, so flooding the code-request endpoint burns budget. Gate SMS behind a first factor so anonymous users cannot trigger it, prefer push, rate-limit per user/IP/device (especially codes never entered), detect anomalies, use a WAF.
Common mistakes
- ✗Treating code guessing as the problem rather than the cost of sending
- ✗Leaving the SMS-send endpoint accessible to anonymous users
- ✗Not rate-limiting requests when a code is requested but never entered
Follow-up questions
- →Why is moving SMS behind a first factor especially effective against bombing?
- →Which metrics help distinguish an attack from a spike in legitimate traffic?
MiddleTheoryOccasionalWhy is account recovery so often the bypass around otherwise strong authentication?
Why is account recovery so often the bypass around otherwise strong authentication?
Recovery is a second door into the account, so the system is only as strong as its weakest path — a mailbox reset undoes a security key. Hold recovery to the primary bar: verified channels, a delay plus notification before an MFA reset, and audit.
Common mistakes
- ✗Letting a mailbox reset override a phishing-resistant primary factor
- ✗Allowing support staff to clear MFA with no delay or notification
- ✗Using knowledge questions whose answers are publicly researchable
Follow-up questions
- →Why does a delay plus notification blunt a social-engineered MFA reset?
- →How do backup codes change the recovery risk compared with support-driven resets?
MiddleDebuggingOccasionalA login handler keeps the pre-login session id — find and fix the flaw.
A login handler keeps the pre-login session id — find and fix the flaw.
The handler reuses the identifier the visitor arrived with, so whoever planted it owns the authenticated session — classic fixation; logout only blanks a field. Regenerate on login and privilege change, destroy on logout, harden the cookie.
Open full question →Common mistakes
- ✗Assuming the session store rotates the identifier on its own at login
- ✗Treating a blanked user field on logout as a destroyed session
- ✗Emitting the session cookie without
HttpOnly,SecureandSameSite
Follow-up questions
- →Which other event besides login must also trigger session regeneration?
- →Why must logout remove the server-side record and not only the cookie?
SeniorTheoryOccasionalHow should services authenticate to each other instead of shared static secrets?
How should services authenticate to each other instead of shared static secrets?
Give each workload its own verifiable identity — mutual TLS certificates or short-lived tokens from a platform identity service — instead of one API key in config. Credentials rotate automatically, are scoped narrowly and revocable without a redeploy.
Common mistakes
- ✗Sharing one long-lived API key across every internal service
- ✗Trusting a caller identity header instead of a cryptographic proof
- ✗Treating network location as authentication for internal calls
Follow-up questions
- →What does mutual TLS prove that a bearer secret in a header does not?
- →How should a break-glass credential for a privileged account be governed?
SeniorTheoryOccasionalHow do you pick idle and absolute session timeouts and invalidate sessions?
How do you pick idle and absolute session timeouts and invalidate sessions?
Ship both: an idle timeout ends a forgotten session, an absolute one caps how long a stolen token stays useful. Invalidate server-side on logout, password reset and privilege change, and offer logout-everywhere. Stateless tokens need short lives.
Common mistakes
- ✗Shipping an idle timeout with no absolute cap on session age
- ✗Believing a password reset revokes issued stateless tokens by itself
- ✗Leaving a session valid across a role or privilege change
Follow-up questions
- →Why does an absolute timeout matter when an idle timeout is already set?
- →How would you implement logout-everywhere for stateless tokens?
SeniorTheoryOccasionalWhat is the blast radius of single sign-on, and how do you contain it?
What is the blast radius of single sign-on, and how do you contain it?
One identity provider fronts every application, so a forged assertion or a compromised provider admin reaches all at once. Contain it with phishing-resistant MFA on the provider, short assertion lives, per-application audience and scope, and revocation.
Common mistakes
- ✗Assuming one credential store means one small blast radius
- ✗Issuing assertions without per-application audience and scope
- ✗Protecting provider administrators no better than ordinary users
Follow-up questions
- →Why does an assertion need an application-specific audience value?
- →Which applications justify step-up authentication even after single sign-on?
SeniorDesignRareA payments dashboard authenticates staff with a password plus a time-based one-time password and issues a web session lasting up to twelve hours. Four operations are sensitive: adding a payout bank account, raising a transfer limit, disabling a second factor, and exporting the customer list. Constraints — about a third of staff have hardware security keys enrolled and the rest do not; the product team rejects any change that forces a full re-login before every sensitive action; mobile and web share one session backend; the regulator requires an auditable record of who approved each sensitive change. Design step-up authentication for this system: say which operations trigger it, which factor a step-up must use, what a completed step-up grants and for how long, how the result is bound to the session and to the specific operation, and what goes into the audit log.
A payments dashboard authenticates staff with a password plus a time-based one-time password and issues a web session lasting up to twelve hours. Four operations are sensitive: adding a payout bank account, raising a transfer limit, disabling a second factor, and exporting the customer list. Constraints — about a third of staff have hardware security keys enrolled and the rest do not; the product team rejects any change that forces a full re-login before every sensitive action; mobile and web share one session backend; the regulator requires an auditable record of who approved each sensitive change. Design step-up authentication for this system: say which operations trigger it, which factor a step-up must use, what a completed step-up grants and for how long, how the result is bound to the session and to the specific operation, and what goes into the audit log.
Trigger step-up only on the sensitive operation set. Require a phishing-resistant factor where one is enrolled, else the one-time password. Bind the result to the session and to that exact operation for a short window, never a global elevated flag, and audit actor, factor and outcome.
Common mistakes
- ✗Granting a global elevated flag instead of binding to one operation
- ✗Reusing the login factors instead of demanding a fresh proof
- ✗Auditing only failures, leaving approved sensitive changes unrecorded
Follow-up questions
- →Why must the step-up result be bound to the operation parameters and not only the session?
- →How do you handle staff without a hardware key without weakening the whole control?