CompTIA Security+ SY0-701 · Threats, Vulnerabilities, and Mitigations · easy

A developer discovers that a C++ network daemon copies a 512-byte user packet into a fixed 128-byte stack array using strcpy() without checking the input length, allowing an attacker to overwrite the function return address. What type of vulnerability is this, and which OS defense randomizes memory locations to hinder exploitation?

Published · Last updated · checked before publication — how we verify questions

Options

  • ABuffer overflow mitigated at the OS level by ASLR memory randomizationCorrect answer
  • BSQL injection mitigated at the database layer by stored procedures
  • CDirectory traversal mitigated by canonicalizing file system paths
  • DCross-Site Scripting mitigated by a Content Security Policy header

Answer: A. Buffer overflow mitigated at the OS level by ASLR memory randomization

Copying unchecked input into a fixed-size stack buffer that overwrites adjacent memory and the return pointer is a Stack Buffer Overflow. Address Space Layout Randomization (ASLR) randomizes the memory addresses of the stack, heap, and shared libraries so an attacker cannot reliably jump to a hardcoded shellcode address.

Why the other options are wrong

  • B. SQL injection mitigated at the database layer by stored procedures — Overwriting a C++ stack return address via strcpy() is a memory buffer overflow, not SQL injection.
  • C. Directory traversal mitigated by canonicalizing file system paths — Directory traversal uses ../ sequences to read arbitrary files, not stack buffer overwrites.
  • D. Cross-Site Scripting mitigated by a Content Security Policy header — XSS is a browser script injection flaw in web pages, not a C++ stack memory corruption bug.

All Threats, Vulnerabilities, and Mitigations questions and the topic overview →

CompTIA and Security+ are trademarks of the Computing Technology Industry Association. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by CompTIA.