🎓 BookMCQ
← Back to 15. Security

📝 Encryption as a Security Tool (9 MCQs)

Converting Readable Data into Protected Ciphertext

Encryption is a cryptographic process that transforms readable plaintext into ciphertext using an algorithm and a key. Operating systems use encryption to protect files, storage volumes, backups, and network communications from unauthorised disclosure. Decryption reverses the transformation for an authorised recipient with the required key, making secure key handling essential to the protection provided.

Why Plaintext Requires Protection at Rest and in Transit

Data may be exposed when stored devices are lost, backups are copied, or network traffic is intercepted. File permissions help control ordinary access but cannot protect information after an attacker obtains an unencrypted copy. Encryption reduces this exposure by making copied data unreadable without the relevant cryptographic key.

Encryption and Decryption with a Key

An encryption algorithm accepts plaintext and a key, then produces ciphertext. The authorised decryption operation uses the corresponding key or key pair to recover the plaintext. The algorithm may be symmetric or asymmetric. Secure systems use established algorithms and authenticated modes rather than inventing proprietary transformations.

Example of Encrypting a Backup File

An administrator encrypts a 100 MB backup before transferring it to remote storage. The remote provider stores ciphertext, so ordinary access to the stored object does not reveal the original files. During restoration, authorised software obtains the required key, verifies the protected data, and decrypts the backup for use.

Confidentiality Gains and Operational Costs

Encryption protects information on disks, removable media, and communication channels. It introduces computational work and requires secure key storage, rotation, recovery, and access procedures. Lost keys may make data unrecoverable, while compromised endpoints can expose plaintext before encryption or after decryption. Authenticated encryption also helps detect unauthorised modification.

Misconceptions About Encryption

'Ciphertext can always be converted back without a key' is false for secure encryption. 'Encryption automatically verifies the sender' ignores the need for authentication mechanisms. 'A strong password alone makes every encryption design secure' overlooks algorithm choice, key derivation, randomisation, and implementation quality.

Exam Focus: Plaintext, Ciphertext and Key Use

Trace encryption and decryption and identify the role of the key in each step. Distinguish protection of data at rest from data in transit. Questions may compare symmetric and asymmetric encryption or ask why authenticated encryption, key recovery, and secure key storage are required for practical systems.

Key Terms of Encryption

  • Plaintext - Information before encryption.
  • Ciphertext - Encrypted representation of information.
  • Encryption key - Parameter controlling encryption.
  • Decryption - Recovery of plaintext from ciphertext.
  • Authenticated encryption - Encryption with integrity protection.
2
Easy
4
Medium
3
Hard

📝 All Encryption as a Security Tool MCQs

Q1. A program copies user input into a local array named buffer[0..63] and then returns from main. Which stack element must the attacker overwrite to hijack execution?

A.Overwrite the saved frame pointer
B.Overwrite the return address ✅
C.Overwrite the buffer size variable
D.Overwrite a global variable
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The correct answer is B because the return address is the pointer the CPU uses to continue execution after a function returns; overwriting it lets an attacker redirect control to malicious code. Overwriting the saved frame pointer (A) would corrupt stack navigation but would not directly change execution flow. The buffer size variable (C) is not typically stored on the stack, and a global variable (D) is unrelated to the function return mechanism. In real attacks, changing the return address is the primary way to run shellcode with the program’s privileges.

Q2. Given a buffer of size 6464 bytes, a shellcode of 3030 bytes, a saved frame pointer occupying 88 bytes, and a return address located immediately after the saved frame pointer, how many NOP bytes must the attacker add to reach the return address?

A.42 ✅
B.38
C.44
D.50
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The correct answer is A (42 NOP bytes). The return address lies after the buffer (64 bytes) and the saved frame pointer (8 bytes), so an attacker must write 64 + 8 = 72 bytes before reaching it. The shellcode occupies 30 bytes, leaving 72 − 30 = 42 bytes for padding. Options B, C, and D give incorrect calculations, either adding or subtracting the wrong amounts. Knowing the exact padding is essential for a reliable exploit, as insufficient NOPs will miss the return address and cause a crash.

Q3. When constructing an exploit for a program compiled without address randomization, which step is most critical to ensure the payload jumps to the attacker‑controlled code?

A.Disable stack canaries
B.Determine the exact address of buffer[0] ✅
C.Modify the source code
D.Use a format‑string vulnerability
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because the exploit needs the precise memory address where buffer[0] resides; the overwritten return address must point exactly to that location to execute the injected code. Disabling stack canaries (A) would prevent detection but does not provide the address. Modifying source code (C) is irrelevant to a binary‑only attack, and a format‑string vulnerability (D) is a different class of bug. Accurate address knowledge is crucial when ASLR is disabled, allowing the payload to be reached reliably.

Q4. A set‑uid root program contains a stack buffer overflow. Which mitigation alone would stop the injected shellcode from executing, even if the return address is overwritten?

A.Stack canaries
B.Address Space Layout Randomization (ASLR)
C.Non‑executable stack (NX)
D.All of the above ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: The correct answer is D; each listed mitigation blocks a different stage of the attack, and together they provide comprehensive protection. Stack canaries (A) detect overflow before the return address is altered, ASLR (B) randomizes memory locations making it hard to guess the target address, and a non‑executable stack (C) prevents the CPU from running injected shellcode even if the return address is compromised. Options A, B, and C alone may still allow execution via return‑to‑libc or ROP techniques, so only the combination fully stops the shellcode.

Q5. An attacker wants the overwritten return address to point to the library function system(). Which technique is required to discover the correct address of system() in the target binary?

A.Use objdump or readelf to find the symbol offset ✅
B.Guess the address
C.Pad with a NOP sled
D.Change compiler optimization flags
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The correct answer is A because tools like objdump or readelf can display the offset of the system() symbol in the linked library, allowing the attacker to compute its absolute address in the target process. Guessing the address (B) is impractical due to address space randomization. Adding a NOP sled (C) helps land the instruction pointer but does not locate the system() function. Changing compiler flags (D) does not reveal runtime addresses. Knowing the exact address of system() enables a return‑to‑libc attack that bypasses the need for custom shellcode.

Q6. Why do buffer‑overflow attacks commonly target the return address rather than other local variables?

A.It is stored next to the buffer
B.Changing it redirects program control flow ✅
C.It holds user data
D.It is protected by canaries
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The correct answer is B because overwriting the return address changes where the program will continue after the function finishes, effectively handing control to attacker‑supplied code. The saved frame pointer (A) is used for stack frame navigation, and corrupting it typically causes a crash rather than a controlled jump. The buffer size variable (C) is not stored on the stack and does not affect execution flow. Stack canaries (D) are protective mechanisms; they do not explain why attackers prefer the return address. Redirecting execution is the core goal of a buffer‑overflow exploit.

Q7. How does a NOP sled improve the reliability of a stack‑based buffer‑overflow exploit?

A.It provides a large landing zone for the instruction pointer ✅
B.It decreases reliability
C.It has no effect
D.It makes the exploit slower
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct answer is A; a NOP sled consists of many no‑operation instructions that create a large region where the instruction pointer can land safely before reaching the actual shellcode. This increases the chance that a slightly imprecise overflow still reaches the payload, improving reliability. Options B and C claim the opposite, which is inaccurate, and option D suggests performance impact, which is irrelevant to exploit success. In practice, attackers use NOP sleds to compensate for uncertainties in exact address calculations.

Q8. Why does a buffer‑overflow vulnerability have a greater impact when the vulnerable program runs with system‑wide permissions?

A.The process executes with elevated privileges ✅
B.The buffer size is larger
C.The code is compiled with aggressive optimizations
D.A debugger is attached to the process
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct answer is A because a program that runs with system‑wide (e.g., root) privileges executes any code it loads with those same privileges; thus, a successful buffer‑overflow can give an attacker full system control. The buffer size being larger (B) does not inherently increase impact. Compilation optimizations (C) affect performance, not privilege escalation. Having a debugger attached (D) is a development concern and does not affect the severity of the vulnerability. Elevated privileges amplify the damage of any code execution flaw.

Q9. What does the abbreviation NOP stand for in assembly language?

A.No operation ✅
B.New operation
C.Not operator
D.Null operation
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The correct answer is A; NOP stands for “no operation,” an instruction that does nothing and simply advances the program counter. This instruction is often used to create padding or NOP sleds in exploits. “New operation” (B), “not operator” (C), and “null operation” (D) are incorrect interpretations of the acronym. Understanding the purpose of a NOP is essential because it allows attackers to build reliable landing zones for shellcode in memory.

🔗 Related Topics (MCQs)