šŸŽ“ BookMCQ
← Back to 15. Security

šŸ“ One time passwords OTP in operating system (12 MCQs)

Temporary Codes for Stronger User Authentication

A one-time password, or OTP, is an authentication code designed for use in a single login or limited validity period. Operating systems and connected authentication services use OTPs as an additional factor alongside ordinary credentials. A code may be generated from a shared secret and time value or from a counter, reducing the value of a code captured during an earlier authentication.

Why Reusable Passwords Need an Additional Factor

Passwords may be stolen or reused across services, allowing attackers to replay them. OTPs introduce a changing value that is difficult to reuse after its accepted period or counter position. They strengthen authentication but can still be exposed through phishing, malware, insecure recovery, or interception of delivery messages.

Time Based and Counter Based Code Generation

Time-based OTP systems derive a short code from a shared secret and a time interval, commonly using TOTP. HOTP uses a counter that advances according to the protocol. The verifier independently calculates the expected value and accepts a matching code within its configured time window or counter allowance.

Example of a Time Based Login Code

A user enters a password and a six-digit authenticator code that changes every 30 seconds. The server calculates the expected code from the shared secret and current time window. If the code matches within the allowed window and has not been improperly reused, authentication can proceed.

Replay Resistance and Delivery Limitations

OTPs improve security because previous codes expire or become invalid after use. Time synchronisation, secure secret storage, attempt limits, and recovery controls remain important. SMS codes are vulnerable to interception and SIM-related attacks, while authenticator codes can be phished in real time. Phishing-resistant security keys provide stronger protection in many environments.

Misconceptions About One Time Passwords

'An OTP remains valid indefinitely' is false because it is time-limited or counter-controlled. 'A six-digit code is impossible to guess' ignores the need for attempt limits. 'Every OTP method is phishing-resistant' is incorrect because attackers can relay entered codes to a genuine service.

Exam Focus: TOTP, HOTP and Replay Prevention

Compare time-based and counter-based OTP generation and identify the shared secret's role. Trace verification within a time window and explain why attempt limits are necessary. Questions may distinguish OTP from an ordinary reusable password or compare authenticator applications, SMS delivery, and phishing-resistant security keys.

Key Terms of OTP Authentication

  • OTP - Code intended for one-time authentication.
  • TOTP - OTP derived from time and a secret.
  • HOTP - OTP derived from a counter and secret.
  • Replay - Reuse of a previously captured credential.
  • Time window - Period during which a code is valid.
2
Easy
6
Medium
4
Hard

šŸ“ All One time passwords OTP in operating system MCQs

Q1. What best describes a one-time password (OTP)?

A.A password that never expires
B.A password that is valid for only a single authentication session āœ…
C.A password that is shared among multiple users
D.A password stored in plaintext on the server
šŸ’” Difficulty: easy | āœ… Correct: B

šŸ“– Explanation: A one-time password is designed to be usable for only one authentication event, after which it becomes invalid. Option B captures this definition precisely. Option A is incorrect because OTPs are short‑lived, not permanent. Option C mischaracterizes OTPs as shared, which defeats their purpose. Option D describes poor storage practice, not the OTP concept. Understanding this definition is essential for recognizing why OTPs improve security in real‑world login systems.

Q2. A user receives a six‑digit OTP via SMS to access their bank account. Which action should the user take to maintain security?

A.Enter the OTP on any website that asks for a code
B.Save the OTP in a notes app for future use
C.Enter the OTP only on the bank’s official login page āœ…
D.Share the OTP with a trusted friend for verification
šŸ’” Difficulty: easy | āœ… Correct: C

šŸ“– Explanation: The OTP must be entered on the legitimate service that generated it—in this case, the bank’s official login page. Option C is correct because it prevents man‑in‑the‑middle attacks. Option A risks phishing, as any site could request the code. Option B creates a persistent record that could be stolen. Option D exposes the secret to another party, compromising the authentication process.

Q3. In a Time‑Based OTP (TOTP) system, how is the current password generated?

A.By hashing a secret key with the current Unix timestamp divided by a time step āœ…
B.By incrementing a counter each time a password is requested
C.By encrypting the user’s static password with a random nonce
D.By storing pre‑computed passwords on the server
šŸ’” Difficulty: medium | āœ… Correct: A

šŸ“– Explanation: TOTP algorithms compute the OTP by applying a hash function to a shared secret key and the current time interval, typically the Unix time divided by a step (e.g., 30 seconds). Option A reflects this process accurately. Option B describes an event‑based HOTP approach. Option C mixes concepts of encryption and static passwords, which is not how OTPs are derived. Option D suggests a server‑side store, contrary to the stateless nature of TOTP.

Q4. A system uses an HMAC‑based OTP (HOTP) where the counter is stored on the client. What must the server do to verify the OTP?

A.Synchronize its own counter with the client’s counter each time
B.Compute the HMAC using the shared secret and the counter value received from the client āœ…
C.Ignore the counter and only check the HMAC output length
D.Reset the counter to zero after each login attempt
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: In HOTP, the client sends the current counter value along with the OTP. The server reproduces the HMAC using the same secret and the received counter to validate the code, making option B correct. Option A is unnecessary because the server does not need to keep its own counter; it trusts the client’s value. Option C ignores the essential counter component, and option D would cause mismatches after the first use.

Q5. Why are OTPs considered more secure than static passwords?

A.They are longer in length
B.They change after every use, reducing the window for replay attacks āœ…
C.They are stored in encrypted form on the server
D.They require biometric verification
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: OTP security stems from their one‑time nature: each code becomes useless after a single authentication, dramatically limiting an attacker’s chance to reuse a captured credential. Option B captures this advantage. Option A may be true but is not the primary security benefit. Option C refers to storage practices, not the dynamic property of OTPs. Option D introduces biometrics, which is a separate factor not intrinsic to OTP mechanisms.

Q6. An attacker intercepts an OTP transmitted over an insecure channel and attempts to reuse it immediately. Which OTP design mitigates this replay attack most effectively?

A.A static password combined with OTP
B.A time‑based OTP that expires after 30 seconds āœ…
C.A longer OTP with 12 digits
D.An OTP that is generated on the server only
šŸ’” Difficulty: medium | āœ… Correct: B

šŸ“– Explanation: Time‑based OTPs have a short validity period (often 30 seconds), so even if an attacker captures the code, it quickly becomes invalid, preventing replay. Option B reflects this protection. Option A still relies on a reusable static password, leaving a replay gap. Option C increases complexity but does not address timing. Option D does not specify expiration, so it does not inherently stop replay attacks.

Q7. Which statement correctly differentiates event‑based (HOTP) and time‑based (TOTP) OTPs?

A.HOTP requires synchronized clocks, while TOTP uses a counter
B.TOTP changes only when the user logs in, HOTP changes every minute
C.HOTP generates passwords based on a moving counter, TOTP generates passwords based on the current time interval āœ…
D.Both HOTP and TOTP rely on user‑entered random numbers
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: HOTP and TOTP differ in their input: HOTP uses a counter that increments with each use, whereas TOTP derives the code from the current time slice, typically a 30‑second interval. Option C accurately describes this distinction. Option A reverses the mechanisms. Option B misstates the behavior of both types. Option D introduces random numbers, which are not part of the standard OTP generation process.

Q8. A company wants to implement OTP for remote VPN access. Which deployment ensures minimal user friction while maintaining strong security?

A.Send OTP via email every login
B.Require users to carry a hardware token and enter a code
C.Use a mobile authenticator app that generates TOTP codes āœ…
D.Ask users to answer security questions instead of OTP
šŸ’” Difficulty: medium | āœ… Correct: C

šŸ“– Explanation: Mobile authenticator apps generate TOTP codes offline, eliminating the need for network delivery and hardware tokens, thus balancing usability and security. Option C is the best choice. Option A depends on email delivery latency and possible compromise. Option B adds hardware costs and inconvenience. Option D replaces OTP with weaker knowledge‑based factors.

Q9. If an attacker obtains the shared secret used for TOTP generation, what is the impact on the system’s security?

A.The attacker can generate valid OTPs for any time interval āœ…
B.The attacker can only guess OTPs with a 50% success rate
C.The attacker can replay previously captured OTPs indefinitely
D.The attacker’s knowledge has no effect without the user’s device
šŸ’” Difficulty: hard | āœ… Correct: A

šŸ“– Explanation: Possessing the secret key enables the attacker to compute the correct OTP for any future time interval, effectively compromising the authentication mechanism. Option A reflects this severe impact. Option B underestimates the attacker’s capability; the secret allows deterministic generation, not random guessing. Option C describes a replay scenario, but with the secret, the attacker can generate fresh codes. Option D is false because the secret alone is sufficient.

Q10. An OTP system uses a 6‑digit numeric code. Assuming uniformly random generation, what is the probability that an attacker guesses the correct OTP on a single attempt?

A.1103\frac{1}{10^3}
B.1106\frac{1}{10^6} āœ…
C.1109\frac{1}{10^9}
D.1220\frac{1}{2^{20}}
šŸ’” Difficulty: hard | āœ… Correct: B

šŸ“– Explanation: A 6‑digit numeric OTP has 10 possibilities per digit, yielding 106=1,000,00010^6 = 1,000,000 total combinations. The chance of a correct guess on one try is therefore 1106\frac{1}{10^6}. Option B correctly expresses this probability. Option A corresponds to a 3‑digit code, Option C to a 9‑digit code, and Option D represents a binary space unrelated to decimal digits.

Q11. Increasing OTP length improves security but may affect usability. Which statement best captures this trade‑off?

A.Longer OTPs are always better, regardless of user impact
B.A moderate length (e.g., 6‑8 digits) balances low guess probability with reasonable entry time
C.Short OTPs improve security because they are easier to remember āœ…
D.Usability is unrelated to OTP length
šŸ’” Difficulty: hard | āœ… Correct: C

šŸ“– Explanation: The optimal balance is achieved with a moderate length that keeps the guessing probability low while remaining practical for users; typically 6‑8 digits achieve this. Option C correctly describes the trade‑off. Option A ignores usability concerns. Option B is plausible but the question asks for the best capture, and the explanation emphasizes the balance rather than an absolute rule. Option D falsely claims no relationship between length and usability.

Q12. A server and a client use TOTP with a 30‑second time step. If their clocks drift apart by up to 45 seconds, what is the maximum number of time steps the server should accept to still validate the OTP?

A.1
B.2
C.3 āœ…
D.4
šŸ’” Difficulty: hard | āœ… Correct: C

šŸ“– Explanation: With a 30‑second step, a 45‑second drift could place the client’s code one step ahead or behind. Accepting the current step plus one step before and after covers a total window of three steps. Therefore, the server should allow a window of three steps (current, previous, next). Option C reflects this calculation. Option A is too narrow, Option B only covers two steps, and Option D is unnecessarily wide, increasing the chance of accepting forged codes.

šŸ”— Related Topics (MCQs)