Chapter 13: Security
Multiple Choice · The CIA Triad
Question 1: Which Goal Was Violated?
Patient records on a hospital file server were encrypted by ransomware. The records were not leaked and their contents were not altered, but doctors could not reach the files for hours. Which component of the CIA triad was directly violated?
C: the data was neither read nor modified, but the service became unusable. Ransomware and DoS attacks target availability. A leak would have violated confidentiality and tampering with records would have violated integrity; non-repudiation concerns signatures and audit logs.
Classic Question · Secret-Key Cryptography
Question 2: Substitution Cipher
The key of a monoalphabetic substitution cipher is in the table. (a) What is the ciphertext of the word ATTACKED? (b) What does the ciphertext LTEXKOZN hide? (c) Although the key space is 26!, why is this cipher easy to break?
| plain | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cipher | Q | W | E | R | T | Y | U | I | O | P | A | S | D | F | G | H | J | K | L | Z | X | C | V | B | N | M |
Show answer
(a) A → Q, T → Z, T → Z, A → Q, C → E, K → A, E → T, D → R: QZZQEATR.
(b) Using the table in reverse: L → S, T → E, E → C, X → U, K → R, O → I, Z → T, N → Y: SECURITY.
(c) 26! ≈ 4 × 10²⁶ keys cannot be brute-forced; but every letter always maps to the same letter. In (a) both T’s became Z and both A’s became Q: letter frequencies survive in the ciphertext. In a few lines of text, matching the most frequent letters (E, T, A in English) recovers the key. Modern symmetric ciphers (AES-GCM, ChaCha20) therefore hide frequencies with their block or stream structure.
Multiple Choice · Digest and Signature
Question 3: Digital Signature
Ali sends a contract to Ayşe; it must be provable that the text was not changed in transit and that it came from Ali, but the text need not be secret. Which scheme is correct?
D: only the owner of the private key can produce the signature and anyone can verify it with the public key; Ali cannot deny it later. A uses the keys backwards. B gives confidentiality but does not prove who the sender is. In C Ayşe also knows the shared key, so she could have produced the signature too: no non-repudiation.
Classic Question · Access Matrix
Question 4: From Matrix to ACL and Capability
The protection matrix is in the table. Write (a) the access control list (ACL) of the object report and (b) the capability list (C-list) of domain D2. (c) In which representation is it easy to revoke D3’s access to report immediately? (d) In which is it easy for D2 to pass its printer right on to D3?
| report | build.sh | printer | |
|---|---|---|---|
| D1 | RW | RX | — |
| D2 | R | — | W |
| D3 | R | X | W |
Show answer
- (a) ACL = a column of the matrix, stored with the object: report → {D1: RW, D2: R, D3: R}.
- (b) C-list = a row of the matrix, owned by the domain: D2 → {report: R, printer: W}.
- (c) ACL: delete D3’s entry from report’s list. With capabilities, you must find and take back D3’s capabilities (and those of everyone it copied them to).
- (d) Capability: D2 hands D3 a copy of the capability; the object’s list is untouched. Sending an open file descriptor to another process in UNIX works the same way.
Step-by-Step Trace · setuid
Question 5: IDs in a setuid Program
Veli (uid 1001) runs a setuid program owned by root. What is the output? Does the last setresuid succeed?
setuid bit: execve sets the effective and saved IDs to the file owner (0); the real ID is Veli’s.
getuid returns the real ID (1001), geteuid the effective ID (0).
Permissions are checked against the effective ID: euid 0 opens the log that only root can write.
Privilege is dropped permanently: all three IDs are 1001. A bug in the remaining code no longer yields root.
Second line: 1001 1001.
An unprivileged process may only switch to the value of r, e or s; all three are 1001: EPERM, −1.
There is no way back; but fd 3 is still writable: an open descriptor acts like a capability and permissions are not rechecked.
/* archive: -rwsr-xr-x, owned by root */ int main(void) { /* run by Veli (uid 1001) */ printf("%d %d\n", getuid(), geteuid()); int fd = open("/var/archive/log", O_WRONLY); uid_t me = getuid(); setresuid(me, me, me); printf("%d %d\n", getuid(), geteuid()); int r = setresuid(0, 0, 0); printf("%d %d\n", r, geteuid()); return 0; }
Multiple Choice · Bell-LaPadula
Question 6: The Bell-LaPadula Rule
Levels: Top Secret > Secret > Confidential > Unclassified. In the Bell-LaPadula model, which operation is allowed for a process running at the Secret level?
A: BLP protects confidentiality: no read up (simple security property), no write down (* property). Reading down is allowed. C and D write down: Secret information could leak to a lower level. B is a read up.
Classic Question · Bell-LaPadula and Biba
Question 7: Two Models Together
A process runs at level “Medium”. For the four operations, does BLP (levels mean secrecy) or Biba (levels mean trustworthiness) allow or deny? If both models are applied together, what can the process access?
(1) Read High (2) Write High (3) Read Low (4) Write Low
Show answer
| operation | BLP | Biba |
|---|---|---|
| (1) read up | deny | allow |
| (2) write up | allow | deny |
| (3) read down | allow | deny |
| (4) write down | deny | allow |
In every row one of the models denies: if both are applied together, the process can read and write only objects at its own level. BLP stops information leaking down, Biba stops tainted data spreading up; the goals conflict.
Step-by-Step Trace · Covert Channel
Question 8: Covert Channel via File Lock
Every 10 ms the server sends one bit by either locking or releasing F. What does the collaborator receive? What is the channel rate, and how long does it take to leak a 256-bit key?
The two processes agreed beforehand. F’s contents are never read or written: no operation that BLP controls takes place.
Bit 7 (0–10 ms): unlock(F): the collaborator can lock it → 0.
Bit 6 (10–20 ms): lock(F): the collaborator’s attempt fails → 1.
Bit 5 (20–30 ms): unlock(F): the collaborator can lock it → 0.
Bit 4 (30–40 ms): unlock(F): the collaborator can lock it → 0.
Bit 3 (40–50 ms): lock(F): the collaborator’s attempt fails → 1.
Bit 2 (50–60 ms): unlock(F): the collaborator can lock it → 0.
Bit 1 (60–70 ms): lock(F): the collaborator’s attempt fails → 1.
Bit 0 (70–80 ms): lock(F): the collaborator’s attempt fails → 1.
8 bits in 80 ms: 01001011 = 0x4B = ‘K’. Rate 1000 / 10 = 100 bit/s; a 256-bit key leaks in 2.56 s. Adding noise lowers the rate but does not close the channel.
/* server (high level), secret = 'K' */ for (int i = 7; i >= 0; i--) { if ((secret >> i) & 1) lock(F); else unlock(F); wait_ms(10); /* ms */ } /* collaborator, in each interval: */ bit = try_lock(F) ? 0 : 1;
Classic Question · Password Storage
Question 9: Brute-Force Time
Passwords consist of 8 lowercase letters (26-letter alphabet); an attacker wants to crack the hash of a single user in a leaked database. (a) How many possible passwords are there? (b) If the hash is plain SHA-256 and 1010 guesses per second are made, what is the worst-case time? (c) If the hash is Argon2id and only 104 guesses per second are possible? (d) What is the role of the salt in this calculation?
Show answer
(a) 268 = 208,827,064,576 ≈ 2.09 × 1011.
(b) 2.09 × 1011 / 1010 ≈ 21 s.
(c) 2.09 × 1011 / 104 ≈ 2.09 × 107 s ≈ 242 days. A slow hash makes every guess 106 times more expensive; a longer password also grows the space exponentially (10 characters, 62 symbols: millions of years).
(d) The salt does not change the time for a single user; but it prevents one computation from being applied to all users at once and rules out precomputed tables: the work multiplies by the number of users. The salt is not secret; it is stored next to the hash.
Classic Question · MFA and TOTP
Question 10: TOTP Code Window
The phone app and the server share the same secret key; the code is generated from the counter T = ⌊t / 30⌋ (t: Unix time in seconds). (a) For t = 1,700,000,000, what is T, and over which range of t is the same code valid? (b) If the server accepts the codes for T − 1, T and T + 1 to allow for clock drift, in which range of t could a code entered at this moment have been generated? (c) Why does password + TOTP count as MFA, and why is it still not enough against phishing?
Show answer
(a) 1,700,000,000 / 30 = 56,666,666.67 → T = 56,666,666. The code is the same from T · 30 = 1,699,999,980 to 1,700,000,009 (30 s).
(b) From T − 1 to T + 1: 1,699,999,950 … 1,700,000,039, a 90-second window.
(c) The password is something you know, the key on the phone is something you have: two different categories. But the user can type the code into a fake site as well; the attacker uses it on the real site before the window closes. A FIDO2 signature, in contrast, is bound to the site’s origin.
Multiple Choice · FIDO2
Question 11: Passkeys and Phishing
A fake login page can easily collect both the password and the TOTP code from a user. Which basic property makes FIDO2/WebAuthn passkeys resistant to this attack?
B: the browser adds the site’s origin to the challenge being signed; a response given to a fake site is invalid on the real site. The server stores only the public key and there is no shared secret (C is wrong). The code that changes every 30 seconds is TOTP and can be phished; length does not prevent phishing.
Step-by-Step Trace · Buffer Overflow
Question 12: How Many Bytes Overflow?
On a 64-bit machine copy_name is called. How many bytes does strcpy write, how many overflow, and how many bytes of the return address are corrupted? How should the line be fixed?
The call sets up the frame: return address, saved frame pointer (rbp) and the 8-byte name. No canary and no padding (-fno-stack-protector).
strcpy copies up to the source’s \0 and does not know the destination size. “Giresun-” exactly fills the array; no \0 yet, so copying continues.
“Ordu-Sam” is written outside the array, over the saved rbp.
“sun” and \0 are written into the low 4 bytes of the return address (little-endian: 73 75 6e 00). Total 19 + 1 = 20 bytes, 20 − 8 = 12 bytes overflowed.
When the function returns, the CPU jumps to the corrupted address: here a crash (SIGSEGV); an attacker who chooses the input redirects execution wherever they like. A canary sits between name and rbp and would catch the corruption before the return.
void copy_name(const char *in) { char name[8]; strcpy(name, in); /* no bounds check */ } /* ret */ /* main: */ copy_name("Giresun-Ordu-Samsun");
Classic Question · TOCTOU
Question 13: Between Check and Use
A setuid root program runs this code. Which vulnerability does it contain? What exactly does the attacker do, and when? How is it fixed?
/* setuid root helper program */ if (access("/tmp/report", W_OK) == 0) { int fd = open("/tmp/report", O_WRONLY); write(fd, data, n); }
Show answer
- TOCTOU (time of check ≠ time of use) race condition:
accesschecks against the real user, whileopenresolves the name again with root privileges. - In the window between the two calls, the attacker deletes
/tmp/reportand puts a symbolic link to/etc/passwdin its place; the root program writes to the protected file. The attempt is repeated many times to hit the window. - Fix: resolve the name only once. Drop privileges and open the file with
open(..., O_WRONLY | O_NOFOLLOW); if needed, check it withfstaton the same descriptor. Useopenatinside a safe directory.
Multiple Choice · Defenses
Question 14: Matching the Defenses
Defenses against buffer overflows are paired with their effects. Which pairing is wrong?
D: NX (DEP) only prevents new code injected into data pages from running. ROP and return-to-libc use code fragments that are already executable; this is why ASLR, CFI and a shadow stack are used together. The root-cause fix is memory-safe languages.
Multiple Choice · Login Spoofing
Question 15: Why Ctrl+Alt+Del?
In a lab, users must press Ctrl+Alt+Del before logging in. Which attack is this rule primarily aimed at?
C: in login spoofing a user program imitates the login screen. The secure attention sequence only invokes the kernel’s real login screen; no user program can intercept this key combination. Against logic bombs and back doors, code review and reproducible builds are used.
Multiple Choice · Types
Question 16: Self-Spreading
Which type of malware copies itself from machine to machine by exploiting an unpatched network service, without the user having to open any file?
A: a worm spreads by itself over the network. A virus attaches to another program and infects when that program is run; a Trojan horse arrives inside a program that looks useful; a rootkit hides itself and other malware.
Multiple Choice · SELinux and AppArmor
Question 17: DAC or MAC?
A web server has been compromised. Using the server’s user account, the attacker can freely change the permissions of a file it owns with chmod; but even where the permission bits would allow it, it cannot access files under /home. Which controls produce these two behaviors, respectively?
B: in DAC the object’s owner sets the permissions (rwx, ACL); the owner, even a malicious one, can change them. In MAC the system sets the policy and a process cannot loosen its own restriction: a SELinux/AppArmor profile confines the compromised process to the files it is allowed to use.
Multiple Choice · Secure Boot
Question 18: A Modified Bootloader
On a machine with Secure Boot enabled, a bootkit has modified the bootloader on disk. What happens when the machine is restarted?
D: in the chain of trust each layer verifies the signature of the next; an unsigned or modified bootloader is not executed. The TPM repairs nothing: in measured boot it stores digests of the components and does not unseal the key on an unexpected measurement. C is the behavior of measured boot alone, with Secure Boot off. Antivirus runs after the kernel; a kit installed before it can fool it.