🎓 BookMCQ
← Back to 15. Security

📝 Authentication as a Security Tool (16 MCQs)

Verifying Identity Before Granting System Access

Authentication is the process of verifying that a user, device, or service is the entity it claims to be. Operating systems perform authentication before establishing user sessions or granting access to protected services. Common methods use knowledge, possession, or inherence factors, and the resulting identity information is then used by authorisation mechanisms to determine permitted operations.

Why User Identification Alone Is Not Enough

A username identifies an account but does not prove who is attempting to use it. Passwords can be guessed, stolen, or reused, while devices and biometric sensors can also be compromised. Authentication therefore requires evidence that the claimant controls an accepted credential or possesses an authorised characteristic.

Credential Verification and Session Establishment

The user submits an authenticator, such as a password or cryptographic token. The operating system or authentication service verifies it against protected credential data or a trusted authentication provider. Successful verification establishes an authenticated session or security token. Later access-control checks use that identity and its associated groups or roles.

Example of a Password and Token Login

An employee enters a username and password, then approves a time-limited code from an authenticator application. The service verifies both factors before establishing the session. A stolen password alone is insufficient when the second factor is properly protected and required for that account.

Authentication Strength and Usability

Strong authentication reduces account takeover and helps protect administrative interfaces, remote access, and sensitive applications. Multi-factor methods can resist password theft, but recovery procedures, phishing, device loss, and session theft remain concerns. Authentication proves control of credentials at a particular time; it does not guarantee that every later action is legitimate.

Misconceptions About Authentication

'Authentication decides what files a user may open' confuses identity verification with authorisation. 'Two passwords are two-factor authentication' is false because both are knowledge factors. 'Successful authentication guarantees a secure session forever' ignores token theft, expiry, privilege changes, and the need for ongoing protection.

Exam Focus: Authentication Factors and Authorisation

Distinguish identification, authentication, and authorisation. Classify passwords, security tokens, and biometrics by their authentication factors. Questions may evaluate multi-factor combinations or trace account login through credential verification and session creation, then explain why resource permissions are checked separately.

Key Terms of Authentication

  • Authentication - Verification of a claimed identity.
  • Credential - Evidence used to prove identity.
  • Factor - Category of authentication evidence.
  • MFA - Authentication using multiple factor categories.
  • Authorisation - Determination of permitted actions.
3
Easy
8
Medium
5
Hard

📝 All Authentication as a Security Tool MCQs

Q1. What is the purpose of a NOP sled in a buffer‑overflow exploit?

A.To align stack frames ✅
B.To pad the payload so the return address lands within executable code
C.To encrypt the shellcode
D.To disable security checks
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: A NOP sled consists of many no‑operation instructions (e.g., 0x900x90) placed before the actual shellcode. Its role is to increase the chance that a overwritten return address will jump into a region that eventually slides into the real payload, because the exact address may be uncertain. Option A describes stack alignment, which is unrelated. Option C suggests encryption, which is not the function of a NOP sled. Option D implies disabling checks, which is also incorrect.

Q2. What does the return address on the stack represent during a function call?

A.The address of the next instruction after the call
B.The address of the function’s first local variable ✅
C.The memory location of the function’s arguments
D.The location where the function’s output is stored
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: When a function is called, the CPU pushes the address of the instruction that should execute after the function returns. This saved address is later popped into the program counter, allowing normal control flow. It does not point to local variables (B), arguments (C), or output storage (D). Understanding this mechanism is essential because overwriting this address is the core of many buffer‑overflow attacks.

Q3. Why does overwriting the return address allow the injected shellcode to run with the same privileges as the vulnerable program?

A.The operating system treats any code at that address as trusted ✅
B.The overwritten address is executed in the same process context
C.The CPU ignores privilege checks for return instructions
D.The compiler automatically elevates the injected code’s rights
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When the return address is replaced, the CPU jumps to the attacker‑controlled location while still inside the original process. The process retains its current privilege level, so the shellcode inherits those rights. Option A is false because the OS does not verify code at the jump target. Option B is true but does not explain why privileges are retained; the key is that privilege checks are bypassed, not that the OS trusts the code. Option D is incorrect because compilers do not modify privileges at runtime.

Q4. How does a stack canary protect against buffer‑overflow attacks?

A.It encrypts the stack contents ✅
B.It places a known sentinel value before the return address
C.It disables the use of strcpy functions
D.It randomizes the location of local variables
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A stack canary is a known value inserted between local buffers and control data such as the return address. Before returning, the program verifies that the canary is unchanged; any overflow that reaches the canary will alter it, causing the program to abort. Encryption (A) is unrelated, and disabling strcpy (C) or randomizing variable locations (D) are separate mitigation strategies.

Q5. What is the relationship between buffer size and the risk of overflow?

A.Larger buffers always increase risk ✅
B.Smaller buffers decrease the chance of overflow if input is unchecked
C.Buffer size does not affect overflow risk
D.Only buffers larger than 128 bytes are vulnerable
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: If a buffer is too small for the data written to it, excess bytes spill into adjacent memory, causing overflow. Therefore, a smaller buffer reduces the chance of overflow only when the program correctly limits input; however, any unchecked input can still cause overflow regardless of size. Option A is misleading because larger buffers can be safer if they accommodate expected input. Option C ignores the fundamental role of size, and D imposes an arbitrary threshold that is not a security rule.

Q6. Why is Address Space Layout Randomization (ASLR) effective against static‑address buffer‑overflow exploits?

A.It encrypts the shellcode ✅
B.It randomizes the location of the stack, heap, and libraries
C.It disables the use of return instructions
D.It forces all binaries to be compiled as position‑independent
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: ASLR randomizes where key memory regions reside each time a program runs, making it difficult for an attacker to predict the exact address of the buffer or return address to overwrite. This uncertainty defeats exploits that rely on fixed addresses. Encryption of shellcode (A) is unrelated, disabling returns (C) would break normal execution, and requiring position‑independent code (D) is a compilation detail, not the primary protective mechanism.

Q7. How can a debugger help an attacker locate the address of buffer[0] in the stack?

A.By showing the source code line numbers ✅
B.By displaying the contents of registers and stack frames
C.By encrypting the memory layout
D.By preventing the program from crashing
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: A debugger can pause execution, inspect memory, and reveal the exact address where buffer[0] resides within the current stack frame. This information allows the attacker to calculate the offset to the return address. Source line numbers (A) are irrelevant to memory addresses, encryption (C) would hide the layout, and preventing crashes (D) is not a debugging function.

Q8. Why is privilege escalation more dangerous when the vulnerable program runs with root privileges?

A.Root programs cannot be exploited ✅
B.The attacker gains the same high‑level rights as the program
C.Root privileges automatically patch the vulnerability
D.The operating system logs all root activity
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When a program executing with root privileges is compromised, the attacker inherits those privileges, enabling actions such as modifying system files, installing backdoors, or disabling security mechanisms. This escalation is far more impactful than compromising a regular‑user process. Option A is false; root programs are often prime targets. Option B correctly states the risk but does not explain why it is more dangerous. Option D is unrelated to the core danger.

Q9. Given a buffer of 64 bytes, an attacker can send 80 bytes of input. Which part of the payload should contain the shellcode to ensure execution after the return address is overwritten?

A.At the very beginning of the input ✅
B.Exactly at byte 64
C.Immediately after the overwritten return address
D.At the end of the input after all padding
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The first 64 bytes fill the buffer; the next 4 or 8 bytes (depending on architecture) overwrite the saved return address. By placing the shellcode immediately after the new return address, the processor jumps to that location when the function returns, executing the payload. Placing it at the start (A) would be overwritten by the return address. Positioning it at byte 64 (B) would overwrite the return address itself, not provide executable code. Ending the input (D) would never be reached.

Q10. If an attacker can only inject 40 bytes, which technique can still allow a successful exploit on a 64‑byte buffer?

A.Using a larger NOP sled ✅
B.Employing return‑oriented programming (ROP) gadgets
C.Increasing the buffer size at runtime
D.Disabling stack protection flags
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: When the payload space is limited, attackers often resort to Return‑Oriented Programming, chaining short instruction sequences (gadgets) already present in the binary to perform malicious actions without needing full shellcode. A larger NOP sled (A) requires more space, increasing the payload size. Changing buffer size (C) or disabling protections (D) are not attacker‑controlled actions.

Q11. In a system with ASLR enabled, what additional step must an attacker typically take to exploit a buffer overflow?

A.Disable the operating system firewall ✅
B.Leak a memory address to defeat randomization
C.Increase the size of the NOP sled
D.Compile the program without optimization
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: ASLR randomizes memory locations, so an attacker must first obtain a memory leak (e.g., via an info‑leak vulnerability) to discover the actual address of a buffer or a useful gadget. Once the address is known, the attacker can craft the exploit. Disabling the firewall (A) does not affect address randomization. Enlarging the NOP sled (C) does not overcome unknown addresses, and compilation flags (D) are under the developer’s control, not the attacker’s.

Q12. A developer replaces strcpy with strncpy to copy argv[1] into a 32‑byte buffer. Which change most directly prevents a buffer‑overflow exploit?

A.Limiting the copy to 31 bytes and adding a null terminator
B.Removing the copy operation entirely ✅
C.Encrypting argv[1] before copying
D.Changing the buffer to a linked list
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Using strncpy with a limit of one less than the buffer size ensures that the copy never writes past the allocated memory and that the string is properly terminated. This directly stops overflow. Removing the copy (B) would break functionality, while encrypting input (C) does not affect size, and switching to a linked list (D) changes the data structure but does not inherently protect against overflow.

Q13. During testing, a program crashes after returning from main. Which stack element is most likely corrupted?

A.The saved frame pointer
B.The global variable table ✅
C.The heap allocation metadata
D.The CPU cache line
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When a function returns, the saved frame pointer is popped from the stack to restore the previous stack frame. Corruption of this pointer often leads to a crash immediately after the return because the stack is misaligned. Global variables (B) reside elsewhere, heap metadata (C) is not on the stack, and CPU cache lines (D) are unrelated to stack integrity.

Q14. An attacker wants the exploited program to open a privileged network port (port < 1024). Which part of the exploit must be modified to achieve this behavior?

A.The NOP sled size
B.The shellcode instructions
C.The return address only ✅
D.The compiler optimization level
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The shellcode contains the actual commands the attacker wants to execute, such as a system call to bind to a privileged port. Modifying the shellcode (C) to include the appropriate system call is necessary. Adjusting the NOP sled (A) only affects landing, not functionality. Changing the return address (B) merely redirects execution but does not define the actions performed. Compiler flags (D) are unrelated to runtime behavior.

Q15. Which mitigation technique would block this buffer‑overflow exploit without altering the program’s source code?

A.Enabling stack canaries at compile time
B.Increasing the buffer size in the source ✅
C.Running the program as a non‑privileged user
D.Disabling all network interfaces
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Stack canaries are inserted by the compiler and cause the program to abort if the canary value is altered, effectively stopping an overflow before the return address is overwritten. This does not require changing the source. Increasing buffer size (B) requires source changes. Running as non‑privileged (C) limits impact but does not prevent the overwrite. Disabling network interfaces (D) is unrelated to memory safety.

Q16. If the vulnerable program runs inside a container that lacks CAP_NET_ADMIN capability, how does this affect the impact of a successful exploit?

A.The exploit will automatically gain host‑level privileges
B.The attacker cannot open privileged ports from within the container ✅
C.The container will prevent any memory corruption
D.The exploit will be unable to modify files on the host filesystem
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Containers can restrict capabilities; lacking CAP_NET_ADMIN means processes inside cannot manipulate network settings, including opening privileged ports. Therefore, even if the attacker gains code execution, they cannot perform that specific privileged action. The exploit still runs with container user privileges, so it may still affect container files, but it does not grant host‑level network control. Options A and D misstate capability effects, and C incorrectly assumes containers stop memory corruption.

🔗 Related Topics (MCQs)