đ Firewalls in operating system security (14 MCQs)
Filtering Network Traffic at System Boundaries
A firewall is a security control that monitors and filters network traffic according to defined rules. Operating systems may include host-based firewalls that restrict incoming and outgoing connections for individual devices. Network firewalls protect broader network boundaries. Rules can consider addresses, ports, protocols, connection state, and application identity to allow or block communication.
Why Network Services Need Controlled Exposure
Every listening service creates a potential communication path into a system. Unrestricted traffic may expose vulnerable services or permit unauthorised connections. Firewalls reduce this exposure by limiting communication to approved services and sources, but they cannot correct vulnerabilities within permitted applications or prevent every attack originating through allowed traffic.
Rule Evaluation and Stateful Connection Tracking
A firewall examines packets or connection metadata against its configured rules. Stateless filtering evaluates individual packets using fields such as source address, destination port, and protocol. Stateful filtering tracks connection state and can allow return traffic belonging to an established connection without treating every packet as an independent new request.
Example of Restricting a Server Port
A server must accept HTTPS connections on TCP port 443 but should not expose its remote administration service to the public internet. The firewall permits approved web traffic and restricts administrative access to a trusted management network. Unauthorised connection attempts to the protected service are blocked or logged.
Traffic Control Benefits and Firewall Limitations
Firewalls reduce attack surface, enforce network segmentation, and help control unwanted communication. Incorrect rules can block legitimate services or expose sensitive ports. They cannot reliably detect every malicious action within encrypted or permitted traffic, nor do they replace endpoint protection, patching, authentication, and intrusion detection.
Misconceptions About Firewall Protection
'A firewall stops every type of malware' is false because malware can arrive through files or allowed connections. 'Blocking incoming traffic also blocks every outgoing threat' ignores outbound communication. 'A stateful firewall decrypts all encrypted traffic automatically' is incorrect because inspection of encrypted content requires additional capabilities and configuration.
Exam Focus: Firewall Rules and Packet Filtering
Interpret rules using source, destination, protocol, port, and connection state. Distinguish stateless packet filtering from stateful inspection and host-based from network firewalls. Given a connection scenario, determine whether traffic is permitted, and explain why firewall rules must be combined with endpoint security and regular configuration reviews.
Key Terms of Firewall Security
- Firewall - Filters network traffic using security rules.
- Packet filtering - Evaluates individual packets against rules.
- Stateful inspection - Tracks connection state during filtering.
- Inbound traffic - Data entering a protected system.
- Outbound traffic - Data leaving a protected system.
đ All Firewalls in operating system security MCQs
Q1. A Linux administrator wants to enable the NX (nonâexecutable) feature for all processes. Which command sequence will correctly activate it on a typical modern distribution?
đ Explanation: The correct sequence is option B because modern Linux systems use the sysctl variableâŻvm.mmap_min_addrâŻto set the lowest allowable memory address for mappings, and enabling execâshield (or the equivalent exec_prot flag) turns on the NX bit for pages. Option A changes address randomization but does not enable NX. Option C sets the minimum address to zero, which disables protection. Option D mixes unrelated settings and does not guarantee NX activation. Enabling NX stops execution of injected stack code, strengthening system security.
Q2. What does the NX (nonâexecutable) bit in a pageâtable entry signify?
đ Explanation: Option C is correct because the NX bit marks a memory page as nonâexecutable, allowing read/write operations while preventing the CPU from fetching instructions from that page. Option A describes a writeâonly restriction, which does not exist in typical page tables. Option B suggests a readâonly page, which is unrelated to execution protection. Option D would make the page completely inaccessible, which would cause a segmentation fault for any access. Understanding NX is essential for mitigating bufferâoverflow attacks.
Q3. A legacy x86 application suffers a stackâbased buffer overflow. The system has NX disabled. Which outcome is most likely when the overwritten return address points to the injected shellcode on the stack?
đ Explanation: When NX is disabled, the stack pages are executable, so the CPU will fetch and run the injected shellcode, allowing the attacker to hijack control flow (option A). Option B would occur only if NX were enabled, causing a protection fault. Option C describes a hostâbased intrusionâprevention system that is not guaranteed. Option D is unrealistic because a buffer overflow that overwrites the return address changes program flow, not normal execution.
Q4. Why are UNIXâlike multiâuser operating systems generally less vulnerable to traditional viruses compared with desktop PCs?
đ Explanation: The primary reason is option B: UNIXâlike systems enforce strict fileâpermission bits that prevent ordinary users from modifying system binaries, limiting a virusâs ability to overwrite trusted executables. Option A is false; encryption is not default. Option C is inaccurate because compiled binaries are common. Option D describes a behavior not present in typical UNIX kernels. By protecting executable files, the OS reduces the impact of selfâreplicating code.
Q5. Which operating system first shipped with builtâin support for the NX (or DEP) feature?
đ Explanation: Windows XP Service PackâŻ2 introduced support for the Data Execution Prevention (DEP) feature, which maps to the hardware NX bit on compatible CPUs. Vista and later versions continued support, but XPâŻSP2 was the first to include it. WindowsâŻ7 and ServerâŻ2003 added DEP later, making option B the correct historical answer.
Q6. A developer writes a function that could be exploited by a stackâbased overflow. Which CPU feature should be relied on to automatically stop execution if the return address points to code on the stack?
đ Explanation: The NX bit (option C) directly prevents execution of instructions located on pages marked nonâexecutable, such as the stack, causing a fault when the CPU tries to run injected code. ASLR (option A) randomizes addresses but does not block execution. CFG (option B) is a software mitigation that validates indirect calls, not a hardware executionârestriction. SMEP (option D) protects kernel memory from userâmode code, unrelated to stack execution in user space.
Q7. How does marking a memory page as nonâexecutable mitigate the risk of a bufferâoverflow attack?
đ Explanation: Option A is correct because a nonâexecutable (NX) page stops the CPU from executing any injected shellcode; an attacker must then resort to returnâoriented programming (ROP), which is considerably harder to craft. Option B describes a fault but does not explain the shift to ROP. Option C is false; NX does not encrypt data. Option D mischaracterizes page protection, as the page remains in the same address space but is simply nonâexecutable. This hardware protection raises the bar for successful exploits.
Q8. In a pageâtable entry, the NX bit is set to 1. What will happen when a process attempts to execute an instruction at virtual address located on that page?
đ Explanation: When the NX bit is 1, the page is marked nonâexecutable, so any attempt to fetch an instruction at triggers a protection fault; the OS typically terminates the offending process (option B). Option D is incorrect because the OS does not silently remap pages to executable status. Option A misstates the effect of NX, which concerns execution, not writes. Option C describes swapping behavior unrelated to execution protection.
Q9. What is the relationship between the hardware NX feature and the software DEP (Data Execution Prevention) mechanism?
đ Explanation: Option C correctly identifies that NX is the hardware flag in page tables, and DEP is the operatingâsystem policy that uses this flag to mark pages as nonâexecutable. Option A reverses the relationship. Option B incorrectly claims DEP is hardware. Option D mischaracterizes both mechanisms, as both target execution of malicious code rather than data protection alone.
Q10. An organization wants to stop emailâborne viruses that attach malicious executables. Which mitigation strategy is most effective?
đ Explanation: Realâtime hostâbased antivirus (option C) scans and disinfects attachments before they reach the user, directly targeting malicious executables. Option B relies on the server to quarantine, but sophisticated threats can evade simple extension checks. Option A blocks all email, which is impractical. Option D does not address the underlying risk of malicious attachments. Effective virus control combines scanning with user education, making option C the best choice.
Q11. Why do multiâuser operating systems with strict executableâfile protections limit the impact of viruses?
đ Explanation: The core reason is option C: fileâsystem permission bits prevent nonâprivileged users from modifying system binaries, so a virus cannot replace trusted executables with malicious versions. Option A is too broad; processes can still create files in user directories. Option B is inaccurate; userâspace programs can still run. Option D describes a versionâcontrol feature not inherent to most OS kernels.
Q12. A firewall is configured to block inbound traffic on TCP portâŻ80. What is the immediate effect on a web server behind this firewall?
đ Explanation: Blocking inbound TCP portâŻ80 (option B) stops external clients from establishing HTTP connections to the server, effectively making the web service inaccessible from the Internet. Option A is false because the port is blocked. Option C misinterprets inbound filtering; outgoing responses are allowed once a connection is established. Option D would require a separate redirection rule, not a simple block.
Q13. How does networkâlevel firewalling complement hostâbased NX protection in defending against codeâexecution attacks?
đ Explanation: Option B correctly explains that firewalls can filter out malicious payloads (e.g., dropping packets that contain known exploit signatures), reducing the chance that malicious code reaches a host, while NX provides a hardware safeguard that prevents execution even if some code slips through. Option A confuses encryption with filtering. Option C describes patch management, not firewalling. Option D mixes authentication concepts unrelated to code execution.
Q14. A security engineer must allow employees to browse the web but prevent remote exploitation of a stack overflow in the browser. Which rule set best meets this requirement?
đ Explanation: The optimal configuration is option C: permitting outbound web traffic (TCPâŻ80/443) lets users browse, while the firewallâs intrusionâprevention system (IPS) can inspect inbound packets for shellcode patterns and drop them, complementing hostâbased NX that blocks execution of any remaining malicious code. Option A lacks the IPS component, leaving a gap. Option B reverses directionality and disables NX, increasing risk. Option D mixes hostâbased NX with firewall rules but does not specify inspection for shellcode, making it less comprehensive than option C.