Vulnerabilities and attack surface

8 free practice questions for the CompTIA® Security+® (SY0-801) exam, from the threats and attacks 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

A vendor announces a remote code execution flaw that affects two servers at a regional hospital. Server A runs a version the vendor still maintains, and the vendor's fix came out last week but is still waiting in the change queue. Server B runs an older version whose vendor support ended last year. Which statement BEST describes the difference between the two servers?
  1. A. Server B's flaw is a zero-day, so it is riskier than Server A's until a patch appears
  2. B. Both servers will be fixed by last week's patch, because the flaw is the same in each
  3. C. Server A can be fixed by installing the existing patch, but Server B will never get one
  4. D. Server B will get its patch later, once the vendor finishes testing it on older versions
Show the answer and explanation

Answer: C. Server A can be fixed by installing the existing patch, but Server B will never get one

Both servers are vulnerable today, but they differ in how the flaw can be resolved. An unpatched system has a fix available that hasn't been applied, and installing it removes the flaw. An unsupported product will never get that fix, so the options are replacement, isolation from untrusted networks, or an alternative source of support. Memory hook: unpatched means "not yet"; unsupported means "never".

Why each option is right or wrong

  • A. Incorrect. A zero-day is a flaw exploited while it is still unknown. This flaw has been announced. Server B's real problem is that its version is out of support, so a patch for it is not late; it will never arrive.
  • B. Incorrect. Vendors build and ship fixes only for versions they still support. Server B's version is past end of support, so last week's fix doesn't cover it.
  • C. Correct. Server A is an unpatched system: a fix exists and only needs to be installed. Server B is an unsupported product: a patch for end-of-life software will never be released, so it needs replacement, isolation, or another source of support.
  • D. Incorrect. End of support means the vendor has stopped producing patches for that version. There is no delayed patch to wait for, so waiting leaves Server B exposed indefinitely.

References

Question 2

A vendor publishes a security advisory and a patch for a critical flaw in a virtual private network (VPN) appliance. The company schedules installation for next quarter's maintenance window. Why does the risk to the appliance usually increase while it waits?
  1. A. The advisory turns the flaw into a zero-day until the patch is installed
  2. B. Public details make attackers more likely to develop working exploits
  3. C. The appliance counts as an unsupported product until it is patched
  4. D. Its severity score rises automatically once a patch has been released
Show the answer and explanation

Answer: B. Public details make attackers more likely to develop working exploits

An unpatched system is one where a fix exists but hasn't been applied. Disclosure tells attackers exactly what to target, so risk usually climbs after an advisory, and postponed routine patching opens more windows of opportunity. The flaw is no longer a zero-day; it is a known, fixable weakness that is still open. The delay itself is the vulnerability.

Why each option is right or wrong

  • A. Incorrect. A zero-day is a flaw exploited while it is still unknown to the vendor and defenders. Once an advisory and patch are public, the flaw is a known, unpatched vulnerability, not a zero-day.
  • B. Correct. Risk usually rises once a vulnerability becomes publicly known, because attackers are more likely to build exploits for it. Every day the patch waits extends that window of opportunity.
  • C. Incorrect. Unsupported means the vendor no longer provides patches. This vendor has just released one, so the appliance is supported but unpatched.
  • D. Incorrect. Releasing a patch doesn't raise a flaw's severity rating. The added risk comes from attacker behavior after disclosure, not from a change in the score.

References

Question 3

A gift card service handles each purchase in two steps. First it reads the card's balance and confirms that it covers the price. Then it subtracts the price from the balance. An attacker sends many purchase requests for one card at the same instant, and several succeed although the balance covered only one. What did the attacker exploit?
  1. A. An error path that skipped subtracting the price when requests failed
  2. B. A timing gap between confirming the balance and subtracting the price
  3. C. A predictable card number that let them guess other cards' balances
  4. D. A replayed session token that bypassed the balance confirmation
Show the answer and explanation

Answer: B. A timing gap between confirming the balance and subtracting the price

In a TOCTOU race condition, the program checks a resource's state (time-of-check) and later acts on that result (time-of-use). If the state can change in between, the check no longer protects the action. Concurrent requests that all check before any of them deducts are a classic way to win the race. The fix is to make the check and the update one atomic operation, for example with a lock.

Why each option is right or wrong

  • A. Incorrect. Mishandled errors can corrupt transactions, but here the extra requests succeeded rather than failed. They all passed the balance check before any deduction happened.
  • B. Correct. This is a time-of-check to time-of-use (TOCTOU) race condition. Each request checked the balance before any other request deducted from it, so every check passed on a state that was stale by the time the deduction ran.
  • C. Incorrect. Guessing card numbers would let an attacker spend other people's cards. It doesn't explain how one card's single balance paid for several purchases.
  • D. Incorrect. Replaying a session token lets an attacker act as a user, but each purchase still runs the same check-then-deduct steps. The overspending comes from timing, not from authentication.

Reference

Question 4

A tenant on a shared hosting platform exploits a flaw in a virtual device that the host emulates for guest virtual machines (VMs). The flaw lets code from the tenant's guest run on the host itself, where the attacker can reach other tenants' VMs. What is this called?
  1. A. VM sprawl
  2. B. Object reuse
  3. C. VM escape
  4. D. Guest privilege escalation
Show the answer and explanation

Answer: C. VM escape

Virtualization's security rests on isolation: a guest should be unable to affect the host or its neighbors. A VM escape breaks that isolation, often through flaws in the hypervisor or the virtual hardware it emulates. Once on the host, the attacker can reach every VM it runs. Keeping hypervisors patched and exposing as few virtual devices as possible reduce the risk.

Why each option is right or wrong

  • A. Incorrect. VM sprawl is the uncontrolled growth of VMs that nobody tracks or maintains. It is a management problem, not a break-out from a guest.
  • B. Incorrect. Object reuse exposes residual data when storage or memory is reassigned without clearing. Here the attacker runs code on the host, which is a different failure.
  • C. Correct. Breaking out of a guest to run code on the underlying host is a VM escape. From the host, the attacker can reach other VMs, so it defeats the isolation that virtualization depends on.
  • D. Incorrect. Gaining administrator rights inside the guest still leaves the attacker contained in that VM. This attack crossed the isolation boundary to the host.

References

Question 5

Attackers begin exploiting a flaw in a widely used file-transfer appliance. The vendor first learns of the flaw from reports of the attacks, and no fix exists yet. Which term BEST describes the flaw at the time of the attacks?
  1. A. Zero-day
  2. B. Unpatched system
  3. C. Unsupported product
  4. D. Misconfiguration
Show the answer and explanation

Answer: A. Zero-day

A zero-day is a flaw attackers exploit before the vendor and defenders know about it, so no patch exists when attacks start. Once the vendor publishes a fix, systems that haven't installed it become unpatched systems instead. The difference matters for response: with a zero-day, mitigations and detection must carry the load until a patch ships.

Why each option is right or wrong

  • A. Correct. A zero-day attack exploits a previously unknown vulnerability, so the vendor has had no time to produce a fix. That matches a flaw the vendor first hears about from the attacks.
  • B. Incorrect. An unpatched system has a fix available that hasn't been installed. Here no fix exists yet, so there is nothing to apply.
  • C. Incorrect. Unsupported means the vendor has stopped issuing fixes for the product. This vendor still supports the appliance; it just hasn't had time to build a fix.
  • D. Incorrect. A misconfiguration is an insecure setting chosen or left in place by the owner. The weakness here is in the vendor's code, not in how the customer set it up.

References

Question 6

A hospital wants to find unauthorized hardware plugged into its wired network, such as small single-board computers hidden behind equipment. Its endpoint detection and response (EDR) console shows only hosts that run the EDR agent. Which approach would MOST reliably find this hardware?
  1. A. Review the EDR console daily for network hosts whose agents stopped reporting
  2. B. Continuously compare devices seen on the network with the authorized inventory
  3. C. Run authenticated vulnerability scans against every host listed in the asset inventory
  4. D. Turn on file integrity monitoring for the servers in the data center
Show the answer and explanation

Answer: B. Continuously compare devices seen on the network with the authorized inventory

A rogue device is an unauthorized node on a network, and attackers sometimes hide one inside a building to get a foothold behind the perimeter. Tools that rely on an installed agent, or that start from the inventory, can't see such a device. Detection has to start from what is actually on the network, such as switch tables or discovery scans, and compare it with what is authorized. NIST also notes that some legitimate components, such as sensors, can't run agents.

Why each option is right or wrong

  • A. Incorrect. A planted device never had the hospital's agent installed, so it never appears in the console. Silent agents point to managed hosts with problems, not to unknown hardware.
  • B. Correct. A rogue device is an unauthorized node, so the reliable test is whether each device on the network appears in the inventory. NIST control CM-8(3) calls for automated detection of unauthorized components, which doesn't depend on an agent.
  • C. Incorrect. Scans aimed at inventoried hosts only reach devices the hospital already knows about. Hardware that was never inventoried is skipped.
  • D. Incorrect. File integrity monitoring watches for file changes on the servers where it runs. It has no view of new hardware joining the network.

References

Question 7

A support portal uses a large language model (LLM) to turn customer questions into database queries. The portal runs each generated query directly, using an account that can read every customer's records. A tester phrases a question so that the model writes a query returning other customers' orders. What is the underlying weakness?
  1. A. The model hallucinated order records that don't exist in the database
  2. B. The portal trusts the model's output instead of validating it like user input
  3. C. The model's training data was poisoned with records from other customers' orders
  4. D. The portal's database stores customer orders without encryption at rest
Show the answer and explanation

Answer: B. The portal trusts the model's output instead of validating it like user input

When an application passes LLM output to a database, shell, or browser without checks, the model becomes a path for user input to reach those systems. The OWASP Top 10 for LLM Applications 2026 calls this improper output handling and lists unparameterized LLM-generated SQL as an example. Its guidance is to treat the model like any other user. Here, validating the generated query and running it with only the requesting customer's permissions would contain the attack.

Why each option is right or wrong

  • A. Incorrect. The records came back from the real database. The model produced a query, not invented data, so hallucination doesn't explain the leak.
  • B. Correct. Whoever writes the prompt can steer the model's output, so it deserves the same distrust as raw user input. Validating each query and running it with the customer's own limited permissions would have stopped this.
  • C. Incorrect. Nothing suggests tampered training data. The orders came from the live database through a query the portal executed.
  • D. Incorrect. Encryption at rest protects stolen disks and backups. The database decrypts data for any authorized query, including this one.

References

Question 8

A developer pushes a commit containing a cloud access key to the company's public code repository. Ten minutes later, the developer notices and pushes a second commit that deletes the file. What should the team do FIRST?
  1. A. Rewrite the repository history so the first commit no longer appears
  2. B. Change the repository's visibility from public to private
  3. C. Add a secret-scanning hook that blocks future commits containing keys
  4. D. Revoke the exposed key and replace it with a newly issued one
Show the answer and explanation

Answer: D. Revoke the exposed key and replace it with a newly issued one

Public repositories are an attack surface because anyone, including attackers who search them for leaked credentials, can read and copy their full history. A later commit that deletes a file leaves the earlier commit intact. The OWASP Secrets Management Cheat Sheet puts revocation first, then rotation, then deleting the secret from the exposed system. Scanning hooks and history cleanup matter, but only after the leaked key stops working.

Why each option is right or wrong

  • A. Incorrect. Cleaning history is a later step and has side effects. Anyone who already cloned or copied the repository still has the key.
  • B. Incorrect. Hiding the repository now doesn't recall copies made while it was public. Attackers search public repositories for leaked credentials, so a copy may already exist.
  • C. Incorrect. Scanning before commits is the right prevention, but it does nothing about the key that already leaked.
  • D. Correct. Deleting the file doesn't remove the key from history or from anyone's copy. Revocation makes the leaked key useless, and OWASP lists immediate revocation as the first containment step.

References