Hardening and mitigations

15 free practice questions for the CompTIA® Security+® (SY0-801) exam, from the operations domain. Pick an answer, then open the explanation to check it.

Every question is original and written for Gapwise with AI. Two separate AI reviewers answered each one without seeing the answer key and checked it against the cited public sources. These are not real exam questions.

Question 1 Multiple answers

A hotel's security cameras share one flat network with the front-desk computers and the payment servers. The cameras only need to send video to a network video recorder (NVR) on the server network. Penetration testers recently used a camera with outdated firmware to reach a payment server. Which two actions together BEST limit the cameras to the traffic they need? (Select two.)
  1. A. Update the camera firmware and change the default passwords
  2. B. Move the cameras to their own virtual local area network (VLAN)
  3. C. Connect a passive network intrusion detection sensor to the camera switch
  4. D. Install antivirus software on the payment servers
  5. E. Allow only camera-to-NVR traffic with an access control list (ACL)
  6. F. Place a decoy camera on the network to attract attackers
Show the answer and explanation

Answers: B. Move the cameras to their own virtual local area network (VLAN); E. Allow only camera-to-NVR traffic with an access control list (ACL)

Segmentation and access control work as a pair. Moving the cameras to their own VLAN creates a separate segment, and an ACL or firewall rule where that segment is routed permits only the video stream to the NVR. Without the ACL, a router that forwards everything between VLANs would still let a camera reach the payment servers. Firmware updates are good hardening, but they don't contain a camera that gets compromised anyway.

Why each option is right or wrong

  • A. Incorrect. Patching and replacing default passwords make each camera harder to compromise, which is worthwhile hardening. They don't limit where a camera can send traffic, so a camera compromised some other way could still reach the payment servers.
  • B. Correct. A dedicated VLAN separates the cameras from the front-desk and payment systems. Traffic leaving the camera VLAN must then pass through a routing point, where it can be filtered.
  • C. Incorrect. A passive sensor analyzes a copy of the traffic and raises alerts. It can report a camera talking to a payment server, but it can't stop the connection.
  • D. Incorrect. Antivirus on the payment servers addresses malware on those hosts. It does nothing to restrict which devices can connect to them over the network.
  • E. Correct. A VLAN alone doesn't block anything if the router forwards all traffic between VLANs. An ACL at that routing point that permits only camera-to-NVR video enforces the restriction and blocks everything else.
  • F. Incorrect. A decoy camera might reveal an intruder probing the network, but it doesn't restrict what the real cameras can reach. Deception supplements segmentation; it doesn't replace it.

References

Question 2 Multiple answers

A company is about to put a new internal web server into production. It will serve only Hypertext Transfer Protocol Secure (HTTPS) to employees. A pre-launch scan finds Telnet and File Transfer Protocol (FTP) services listening, a vendor default administrator account with its factory password, and operating system patches three months out of date. Which three actions BEST harden the server? (Select three.)
  1. A. Disable the Telnet and FTP services
  2. B. Place a decoy server next to it to attract attackers
  3. C. Connect a network intrusion detection sensor in front of it
  4. D. Change the factory password on the default administrator account
  5. E. Install the missing operating system patches
  6. F. Extend the server's log retention to one year
Show the answer and explanation

Answers: A. Disable the Telnet and FTP services; D. Change the factory password on the default administrator account; E. Install the missing operating system patches

Hardening removes ways to attack a system, ideally before it goes live. Turning off services the server doesn't need, installing missing patches, and replacing default credentials each close a specific path the scan found. A decoy, a detection sensor, and longer log retention help detect or investigate attacks, but they leave the weaknesses in place.

Why each option is right or wrong

  • A. Correct. The server needs only HTTPS, so Telnet and FTP are nonessential services. Each one is an extra way in, and both normally send credentials in cleartext, so turning them off shrinks the attack surface.
  • B. Incorrect. A decoy can reveal attackers who probe the network, but it changes nothing on the real server. Every weakness the scan found would still be there.
  • C. Incorrect. A sensor can detect attacks against the server, but it doesn't remove the open services, the default password, or the missing patches. Detection complements hardening; it doesn't replace it.
  • D. Correct. Factory default passwords are widely published, so an attacker could sign in as administrator. Changing default credentials before first use is a basic hardening step.
  • E. Correct. Patching removes known vulnerabilities that attackers could exploit. Hardening guidance pairs patching with turning off nonessential services.
  • F. Incorrect. Longer log retention helps investigations after an incident, but it doesn't remove any weakness. The services, the password, and the missing patches would all still be exploitable.

References

Question 3

A school district has 2,400 Windows laptops joined to its on-premises Active Directory domain. A new security baseline requires disabling an outdated file-sharing protocol, locking the screen after 10 minutes, and turning on the host firewall. The settings must be applied centrally, and laptops must keep receiving them without anyone touching each device. Which approach BEST meets these requirements?
  1. A. Have technicians set each laptop's local security policy by hand
  2. B. Use network access control (NAC) posture checks to block noncompliant laptops
  3. C. Add the baseline settings to the acceptable use policy that staff sign
  4. D. Deploy the baseline in a Group Policy Object (GPO) scoped to the laptops
Show the answer and explanation

Answer: D. Deploy the baseline in a Group Policy Object (GPO) scoped to the laptops

Group Policy is the built-in way to push and keep configuration settings on Windows computers joined to an Active Directory domain. A GPO holding the baseline, linked to the organizational unit that contains the laptops, applies the settings at startup and refreshes them in the background. That makes it a standard tool for hardening Windows systems at scale. NAC posture checking is the tempting distractor, but it only decides whether a device may connect; it doesn't configure the device.

Why each option is right or wrong

  • A. Incorrect. Local policy can hold the right settings, but configuring 2,400 laptops by hand is slow and error-prone. Nothing reapplies the settings later, so it fails the requirement for central, ongoing management.
  • B. Incorrect. NAC posture checks can verify that a laptop has the settings before it connects, but they don't configure anything. Laptops missing the baseline would simply be blocked.
  • C. Incorrect. An acceptable use policy tells staff what is expected, but it is a directive control. It doesn't change any laptop's configuration.
  • D. Correct. Group Policy centrally manages Windows settings for domain-joined computers. A GPO linked to the organizational unit that holds the laptops applies the baseline to every laptop, and background refreshes keep applying it.

References

Question 4

A university's security operations center (SOC) alerts whenever one account fails to sign in five times within 10 minutes. The rule fires hundreds of times a day, mostly for mistyped passwords. Last week it stayed silent while one external address tried a single common password against 900 different accounts. Which change would BEST detect this kind of attack without adding to the alert noise?
  1. A. Raise the per-account threshold to 20 failures in 10 minutes
  2. B. Lower the per-account threshold to two failures in 10 minutes
  3. C. Alert when one source fails sign-ins across many accounts
  4. D. Lock each account for an hour after three failed sign-ins
Show the answer and explanation

Answer: C. Alert when one source fails sign-ins across many accounts

Effective alerting matches the rule to the attack pattern. Password spraying tries one or a few common passwords against many accounts to stay under per-account lockout and alert thresholds, so the signal is failures spread across many accounts from one source. Moving the per-account threshold up or down only trades noise against missed attacks, because a spray never trips it.

Why each option is right or wrong

  • A. Incorrect. A higher per-account threshold would cut noise, but a spray tries each account only once or twice. The attack would still stay under any per-account limit.
  • B. Incorrect. A lower threshold would make the rule fire even more often on mistyped passwords. A spray that tries each account once would still never reach two failures on one account.
  • C. Correct. Password spraying spreads a few guesses across many accounts to stay under per-account limits, so the telling pattern is many accounts failing from the same source. A user who mistypes a password fails on one account only, so this rule stays quiet for ordinary typos.
  • D. Incorrect. Lockouts are a preventive control, and sprayers deliberately try each account fewer times than the lockout limit. Aggressive lockouts would also let an attacker lock out many users on purpose.

Reference

Question 5

An online retailer's web servers terminate Transport Layer Security (TLS) themselves, and policy forbids decrypting customer traffic anywhere else. A network intrusion detection sensor on the server segment has missed several injection attempts against the checkout application. Which control would BEST detect and block such attacks?
  1. A. Replace the sensor with an inline network intrusion prevention system (NIPS) appliance
  2. B. Install a host-based intrusion prevention system (HIPS) agent on each web server
  3. C. Add file integrity monitoring to the system directories of each web server
  4. D. Load additional injection signatures onto the existing network detection sensor
Show the answer and explanation

Answer: B. Install a host-based intrusion prevention system (HIPS) agent on each web server

Network sensors can't analyze what is inside encrypted sessions, but an agent on the endpoint sees the activity after decryption. That makes a host-based intrusion prevention system (HIPS) the right fit when TLS ends on the server itself. An inline network device or more signatures are tempting, but both still look only at ciphertext. Memory hook: inspect where the traffic is readable.

Why each option is right or wrong

  • A. Incorrect. An inline NIPS can block traffic, but on this segment it sees the same TLS-encrypted requests the current sensor sees. Policy forbids decrypting them there, so it still can't read the injection strings.
  • B. Correct. The agent runs on the server after TLS has been terminated, so it sees the decrypted requests and the application's activity. Its prevention features can stop the attack on the host without decrypting traffic anywhere else.
  • C. Incorrect. File integrity monitoring compares files with known-good values and reports changes after they happen. It doesn't inspect incoming requests, so it would neither see nor block an injection attempt.
  • D. Incorrect. New signatures don't help a sensor that can't read the payload. The injection strings travel inside encrypted sessions, so the signatures have nothing to match.

References

Question 6

A secrets scanner flags a cloud access key in a commit that has sat in a public code repository for three weeks. The key is still active in the cloud account. What should the team do FIRST?
  1. A. Rewrite the repository's history to purge the commit
  2. B. Revoke the exposed key with the cloud provider
  3. C. Change the repository's visibility to private
  4. D. Add the file that held the key to the ignore list
Show the answer and explanation

Answer: B. Revoke the exposed key with the cloud provider

Finding a secret is only half the job: a secret found in a repository must be treated as compromised. OWASP lists immediate revocation first among containment steps, followed by rotation and removal from code and logs. Rewriting history or hiding the repository feels like cleanup, but it can't recall copies already taken. Kill the credential first, then clean up.

Why each option is right or wrong

  • A. Incorrect. Purging history removes the key from the repository going forward, but anyone who cloned or scraped it in three weeks still has a working copy. Clean up history only after the key is dead.
  • B. Correct. Once a secret has been public, assume someone copied it. Revoking it at the provider makes every copy useless, which is the first containment step. Then issue a replacement and clean up the repository.
  • C. Incorrect. Making the repository private stops new viewers. It does nothing about copies taken during the past three weeks, and the key keeps working.
  • D. Incorrect. An ignore list only keeps untracked files out of future commits. The key is already committed, so this changes nothing about the exposure.

References

Question 7

A Linux server hosts a public web application that runs under its own unprivileged account. The security team wants a compromised web server process to be unable to read files outside its own content and configuration, even where Unix permissions would allow it. File owners must not be able to loosen this restriction. Which control BEST meets these requirements?
  1. A. Tighter Unix permissions that each file's owner sets on the sensitive files
  2. B. A file integrity monitor that alerts whenever a sensitive file changes
  3. C. Full-disk encryption of the server's data volumes, with keys held in a hardware module
  4. D. Security-Enhanced Linux (SELinux) in enforcing mode, confining the web server's domain
Show the answer and explanation

Answer: D. Security-Enhanced Linux (SELinux) in enforcing mode, confining the web server's domain

SELinux is a mandatory access control (MAC) system: its policy, not the user, decides what each process domain may access. Standard Unix permissions are discretionary access control (DAC), so owners can loosen them, and SELinux is checked in addition to them. Confining the web server's domain limits a compromise to the files the policy grants. Memory hook: DAC is the owner's choice; MAC is the policy's rule.

Why each option is right or wrong

  • A. Incorrect. Unix permissions are discretionary: each owner decides them and can loosen them again, which the requirement forbids. A file left readable by everyone stays readable to a compromised web server.
  • B. Incorrect. Integrity monitoring detects changes to files after the fact. It doesn't stop a compromised process from reading anything.
  • C. Incorrect. Disk encryption protects data on a powered-off or stolen drive, wherever its keys are held. A running process sees decrypted files, so it doesn't limit what a compromised web server can read.
  • D. Correct. SELinux enforces mandatory access control: the policy limits the web server's domain to the file types it needs, and neither the process nor file owners can override it.

References

  • The SELinux NotebookSELinux Notebook, Mandatory Access Control chapter (src/mac.md)
  • The SELinux NotebookSELinux Notebook, SELinux Overview, Is SELinux useful, item 4 (src/selinux_overview.md)
  • CSRC GlossaryGlossary term: mandatory access control (NIST SP 800-53 Rev. 5 definition)

Question 8 Multiple answers

A firewall team is sorting its policy requirements. Which two requirements need application-layer (Layer 7) inspection rather than Layer 3 and Layer 4 filtering alone? (Select two.)
  1. A. Deny all traffic from the 198.51.100.0/24 address range
  2. B. Block executable attachments in inbound email
  3. C. Allow only Transmission Control Protocol (TCP) port 443 from the internet to the web server
  4. D. Let staff download from external File Transfer Protocol (FTP) servers but not upload to them
  5. E. Drop inbound packets that don't belong to a connection in the state table
Show the answer and explanation

Answers: B. Block executable attachments in inbound email; D. Let staff download from external File Transfer Protocol (FTP) servers but not upload to them

Packet filters decide on addresses, protocols, and ports, and stateful inspection adds awareness of transport-layer connection state. Neither looks inside the application data. Spotting an executable attachment or an FTP upload command requires analyzing the application protocol, which is what an application (Layer 7) firewall does. Memory hook: if the rule must know what's said inside the conversation, it's Layer 7.

Why each option is right or wrong

  • A. Incorrect. Source addresses are in the network-layer header, so a basic packet filter can enforce this.
  • B. Correct. Attachments live inside the email protocol's content. Only a firewall that analyzes the application protocol can see what type of file is attached.
  • C. Incorrect. Protocol and destination port are transport-layer fields, which Layer 4 filtering handles.
  • D. Correct. Uploads and downloads use the same FTP connection and port. Telling them apart means reading the FTP commands, such as put, at the application layer.
  • E. Incorrect. Stateful inspection tracks transport-layer connection state; it doesn't need to read application data.

References

Question 9

A small architecture firm has one office, one internet connection, and a part-time IT contractor. It needs firewalling, intrusion prevention, gateway antivirus, and web content filtering for its staff. The contractor wants to manage all of them through one policy on one device. Which solution BEST fits?
  1. A. A web application firewall (WAF) in front of the firm's file server
  2. B. A network intrusion detection system (NIDS) on a switch mirror port
  3. C. A unified threat management (UTM) appliance at the network perimeter
  4. D. A stateful firewall with access control lists (ACLs) at the perimeter
Show the answer and explanation

Answer: C. A unified threat management (UTM) appliance at the network perimeter

A UTM appliance combines a firewall with functions such as malware detection, intrusion prevention, and content filtering in one system. NIST notes the idea is that policy is easier to set and maintain on one system than on many at the same location. That suits a small office with little IT staff, as long as the appliance has enough capacity for every function turned on.

Why each option is right or wrong

  • A. Incorrect. A WAF protects web applications from attacks in incoming web requests. It doesn't filter staff browsing or scan traffic for malware at the perimeter.
  • B. Incorrect. A NIDS on a mirror port only watches copies of traffic and raises alerts. It provides no firewalling, blocking, antivirus, or content filtering.
  • C. Correct. A UTM appliance combines the firewall with intrusion prevention, malware scanning, and content filtering, all managed from one policy.
  • D. Incorrect. A stateful firewall filters on addresses, ports, and connection state. On its own it adds no intrusion prevention, antivirus, or content filtering.

Reference

Question 10 Multiple answers

A credit union sends member notices from lakeshorecu.example. Its Sender Policy Framework (SPF) record ends with ~all, and both SPF and DomainKeys Identified Mail (DKIM) pass with alignment. Its Domain-based Message Authentication, Reporting, and Conformance (DMARC) record is v=DMARC1; p=none; rua=mailto:dmarc@lakeshorecu.example. The credit union wants mail apps that support Brand Indicators for Message Identification (BIMI) to show its logo beside these notices. The logo file is already hosted on its website in a format BIMI accepts. Which two actions does BIMI require? (Select two.)
  1. A. Change the DMARC policy to p=quarantine or p=reject
  2. B. Change the SPF record's ending from ~all to -all
  3. C. Publish a TXT record at default._bimi.lakeshorecu.example that points to the logo
  4. D. Add a BIMI-Location header with the logo's web address to every outgoing notice
  5. E. Sign the lakeshorecu.example zone with Domain Name System Security Extensions (DNSSEC)
Show the answer and explanation

Answers: A. Change the DMARC policy to p=quarantine or p=reject; C. Publish a TXT record at default._bimi.lakeshorecu.example that points to the logo

BIMI is not an authentication protocol; it builds on DMARC. A receiver shows the logo only for authenticated mail from a domain whose DMARC policy is at enforcement (quarantine or reject), so p=none rules it out. The domain owner then publishes a BIMI Assertion Record in DNS, by default at default._bimi.<domain>, pointing to the logo. Memory hook: enforce DMARC first, then publish the BIMI record.

Why each option is right or wrong

  • A. Correct. BIMI requires a strong DMARC policy of quarantine or reject. Receivers must not perform BIMI processing for a domain whose policy is p=none, so the logo can't appear until the policy is enforced.
  • B. Incorrect. DMARC already passes through the aligned SPF and DKIM results. BIMI depends on an enforcing DMARC policy, not on a stricter SPF qualifier, so ~all versus -all doesn't decide whether the logo appears.
  • C. Correct. A domain owner states its BIMI preferences in a DNS TXT record, by default at default._bimi.<domain>. The record's l= tag gives the location of the logo file.
  • D. Incorrect. Only the receiving mail system may create the BIMI-Location header, after its own checks pass. It must remove or rename any BIMI-Location header that arrives with a message, so a sender-added one is discarded.
  • E. Incorrect. DNSSEC protects DNS answers from forgery, but the BIMI Internet-Draft doesn't require it. Receivers would still skip BIMI while the DMARC policy stays at p=none.

References

Question 11 Multiple answers

A water utility issues tablets to its meter readers and manages them with mobile device management (MDM). The tablets hold customer names and addresses. Tablets are sometimes lost, and nobody notices for weeks. Policy requires customer data on a missing tablet to be erased automatically, without waiting for anyone to report it missing. Which two MDM policy settings meet this requirement? (Select two.)
  1. A. Wipe the tablet after 10 consecutive failed passcode attempts
  2. B. Wipe the tablet when an administrator sends a remote wipe command
  3. C. Lock the tablet remotely as soon as its user reports it missing
  4. D. Wipe the tablet if it hasn't checked in with the MDM for 7 days
  5. E. Require full-device encryption protected by a six-digit passcode
  6. F. Alert the help desk when a tablet leaves the utility's service area
Show the answer and explanation

Answers: A. Wipe the tablet after 10 consecutive failed passcode attempts; D. Wipe the tablet if it hasn't checked in with the MDM for 7 days

MDM policies can make a device wipe itself without an administrator's command. NIST lists two such triggers: too many incorrect authentication attempts, and too long a time without checking in with the management system. A remote wipe or lock still depends on someone noticing the loss first. Encryption remains wise, but it protects data rather than erasing it.

Why each option is right or wrong

  • A. Correct. MDM can wipe a device after a set number of incorrect authentication attempts. Anyone who tries to guess the passcode triggers the erase, and no one has to report the loss first.
  • B. Incorrect. A remote wipe happens only after someone suspects the tablet is lost and an administrator acts. The policy says erasure must not wait for that report.
  • C. Incorrect. A remote lock depends on a report and doesn't erase anything. The customer data stays on the tablet.
  • D. Correct. MDM can wipe a device after a set time without checking in to the management system. A tablet that drops out of contact erases itself even if nobody has noticed it is gone.
  • E. Incorrect. Encryption protects the data while the tablet is locked, but it doesn't erase anything. The policy calls for automatic erasure.
  • F. Incorrect. The alert tells staff where the tablet went, but a person still has to act on it. An alert by itself erases nothing.

References

Question 12

A hospital's application allow list permits any program signed by the workstation operating system's vendor, plus a short list of approved clinical apps. IT staff manage workstations with one approved third-party remote administration tool. In a recent intrusion, an attacker used a built-in, vendor-signed remote command tool that IT never uses to run commands across workstations. Which change BEST closes this gap while keeping IT's approved tool working?
  1. A. Add deny rules for the operating system's unused remote command tools
  2. B. Replace the allow list with a block list of known malware hashes
  3. C. Restrict the vendor-signature rule to the operating system folder
  4. D. Require multifactor authentication (MFA) for the approved administration tool
Show the answer and explanation

Answer: A. Add deny rules for the operating system's unused remote command tools

Broad allow rules, such as trusting everything a vendor signs, also admit built-in tools that attackers use to live off the land. Joint government guidance on these attacks says to pick a minimal set of administrative tools, then block or alert on all others. Adding deny rules for the unused built-ins keeps the allow list's protection and closes the gap. Memory hook: allow the known-good set, then block the risky extras inside it.

Why each option is right or wrong

  • A. Correct. Deny rules carve the unneeded built-in tools out of the broad vendor-signature rule. The approved third-party tool and everything else on the allow list keep working.
  • B. Incorrect. The built-in tool is legitimate, vendor-signed software, so no malware hash list would include it. Dropping the allow list would also let any unknown program run.
  • C. Incorrect. Built-in tools are installed in the operating system's own folders. A rule limited to those folders would still allow the tool the attacker used.
  • D. Incorrect. MFA protects sign-ins to the approved tool, but the attacker never used that tool. The built-in tool would still run.

References

Question 13

A retailer hires a service to send order receipts. The service uses the retailer's domain in the SMTP envelope sender address and sends from a fixed IP address. The retailer's Sender Policy Framework (SPF) record lists only its own mail servers by IP address, and receivers report SPF failures for the service's receipts. Which change will authorize the service in SPF while keeping the existing servers authorized?
  1. A. Add the service's mail server as an MX host for the retailer's domain
  2. B. Add the service's sending IP address to the retailer's existing SPF record
  3. C. Enable DKIM signing for the service's receipts
  4. D. Add the retailer's mail servers to the service's own SPF record
Show the answer and explanation

Answer: B. Add the service's sending IP address to the retailer's existing SPF record

Receiving servers use SPF to check whether the connecting mail server is authorized to send for the SMTP envelope sender’s domain. The service sends using the retailer’s domain, so adding its IP address to the retailer’s existing SPF record authorizes it alongside the existing servers.

Why each option is right or wrong

  • A. Incorrect. MX records direct inbound mail. The retailer authorizes outbound servers by listing their addresses directly in its SPF record.
  • B. Correct. SPF evaluates the IP address of the server sending the message against the policy for the envelope sender’s domain. Adding the service’s address authorizes it alongside the retailer’s existing servers.
  • C. Incorrect. DKIM uses a signature to associate mail with a signing domain. SPF evaluates the sending IP address against a separate DNS policy.
  • D. Incorrect. The receivers check the retailer’s SPF record because the envelope sender address uses the retailer’s domain. The service’s own record applies when the envelope sender address uses the service’s domain.

References

Question 14

A bank owns several lookalike domains that it registered only to keep them away from fraudsters. None of them will ever send email. Attackers have started using one of them as the envelope sender on phishing messages. Which Sender Policy Framework (SPF) record should the bank publish for each of these domains?
  1. A. v=spf1 -all (result for any sender: fail)
  2. B. v=spf1 ~all (result for any sender: softfail)
  3. C. v=spf1 ?all (result for any sender: neutral)
  4. D. v=spf1 +all (result for any sender: pass)
Show the answer and explanation

Answer: A. v=spf1 -all (result for any sender: fail)

For a domain that sends no mail, RFC 7208 recommends the record v=spf1 -all. Because nothing else is listed, every host reaches -all and gets a fail result, which explicitly says the host isn't authorized. Softfail (~) is a weaker statement that receivers shouldn't reject on alone, neutral (?) asserts nothing, and +all authorizes everyone. Qualifier memory hook: plus passes, minus fails, tilde hedges, question mark shrugs.

Why each option is right or wrong

  • A. Correct. With no other mechanisms, every sending host reaches -all and gets a fail result, an explicit statement that it isn't authorized. RFC 7208 gives this exact record for a domain that sends no mail.
  • B. Incorrect. Wrong. ~all returns softfail: the domain believes the host isn't authorized but won't make a strong statement. Receivers shouldn't reject on softfail alone, which is too weak for a domain that never sends mail.
  • C. Incorrect. Wrong. ?all returns neutral, which makes no assertion either way. Receivers must treat neutral exactly like having no SPF record at all.
  • D. Incorrect. Wrong. +all gives every host on the internet a pass, so the attackers' servers would be authorized to use the domain.

References

Question 15

An administrator moves an internal web application to TCP port 8642 on a Linux server running Security-Enhanced Linux (SELinux) in enforcing mode. The web service now fails to start. The audit log shows that SELinux denied the web server's domain the name_bind permission on TCP 8642. Which action BEST fixes this?
  1. A. Restore the web root's default file contexts with restorecon
  2. B. Assign TCP 8642 to the web server's port type with semanage port
  3. C. Switch SELinux to permissive mode so the service can bind the port
  4. D. Open TCP 8642 for inbound connections in the host firewall
Show the answer and explanation

Answer: B. Assign TCP 8642 to the web server's port type with semanage port

SELinux controls network ports as well as files. Type enforcement rules allow a domain to name_bind only to the port types it's granted, and each port must be labeled with a type through semanage or portcon statements. Labeling the new port with the web server's port type is the targeted fix. Relabeling files and opening the firewall address the wrong object, and permissive mode switches off enforcement entirely.

Why each option is right or wrong

  • A. Incorrect. Wrong. restorecon resets file labels. The denial concerns binding a network port, which is a separate object with its own label.
  • B. Correct. Policy lets a domain bind only to port types it has been granted, and each port gets its type through semanage or portcon statements. Giving 8642 the web server's port type lets the existing policy allow the bind without loosening anything else.
  • C. Incorrect. Wrong. In permissive mode SELinux loads the policy but stops enforcing it. That removes protection for the whole system to fix one port label.
  • D. Incorrect. Wrong. The service fails while binding the port locally, before any connection arrives. A firewall rule for inbound traffic doesn't change SELinux's decision.

References

  • The SELinux NotebookSELinux Notebook, Networking Support, Socket controls: Access Control for Network Ports (src/network_support.md)
  • The SELinux NotebookSELinux Notebook, SELinux Permissive and Enforcing Modes (src/modes.md)