nerdexam
CompTIA

CAS-003 · Question #921

A developer implements the following code snippet: Which of the following vulnerabilities does this code snippet resolve?

The correct answer is B. Buffer overflow. The code snippet (though not displayed) implements input size validation or uses safe memory-handling functions such as bounds checking, limiting input length, or replacing unsafe functions like strcpy() with safer alternatives like strncpy(). Buffer overflow vulnerabilities…

Research, Development and Collaboration

Question

A developer implements the following code snippet:

Which of the following vulnerabilities does this code snippet resolve?

Exhibit

CAS-003 question #921 exhibit

Options

  • ASQL injection
  • BBuffer overflow
  • CMissing session brat
  • DInformation leakage

How the community answered

(22 responses)
  • A
    14% (3)
  • B
    73% (16)
  • C
    5% (1)
  • D
    9% (2)

Explanation

The code snippet (though not displayed) implements input size validation or uses safe memory-handling functions such as bounds checking, limiting input length, or replacing unsafe functions like strcpy() with safer alternatives like strncpy(). Buffer overflow vulnerabilities occur when more data is written to a fixed-size memory buffer than it can hold, causing data to overflow into adjacent memory regions. Attackers exploit this to overwrite return addresses, inject shellcode, or crash programs. By enforcing input size limits or using bounds-checked functions, the code prevents memory corruption. SQL injection (A) would require parameterized queries; missing session tokens (C) would require session management code; information leakage (D) would require suppressing error messages or data masking.

Topics

#buffer overflow#secure coding#input validation#vulnerability remediation

Community Discussion

No community discussion yet for this question.

Full CAS-003 Practice