SY0-501 · Question #485
An analyst is reviewing a simple program for potential security vulnerabilities before being deployed to a Windows server. Given the following code: void foo (char *bar) { car random_user_input[12]…
The correct answer is B. Buffer overflow. The code copies an unchecked user-supplied string into a fixed 12-byte buffer using strcpy, which does not perform bounds checking and can overwrite adjacent memory.
Question
An analyst is reviewing a simple program for potential security vulnerabilities before being deployed to a Windows server. Given the following code:
void foo (char *bar) { car random_user_input[12]; stropy (random_user_input, bar); } Which of the following vulnerabilities is present?
Options
- ABad memory pointer
- BBuffer overflow
- CInteger overflow
- DBackdoor
How the community answered
(53 responses)- A4% (2)
- B75% (40)
- C15% (8)
- D6% (3)
Why each option
The code copies an unchecked user-supplied string into a fixed 12-byte buffer using strcpy, which does not perform bounds checking and can overwrite adjacent memory.
A bad memory pointer vulnerability involves dereferencing null, uninitialized, or dangling pointers; the code here uses a valid stack-allocated array, so pointer misuse is not the primary issue.
The function allocates a fixed-size buffer of 12 characters (random_user_input[12]) and then uses strcpy() to copy an arbitrary-length user-supplied string into it without any length validation. If the input string exceeds 12 bytes, strcpy() will write beyond the buffer boundary, overwriting adjacent stack memory - a classic stack-based buffer overflow vulnerability that attackers can exploit to hijack control flow or execute arbitrary code.
An integer overflow occurs when arithmetic on integer values exceeds the type's maximum range, causing unexpected wraparound; no integer arithmetic is performed in this code.
A backdoor is an intentional hidden mechanism for unauthorized access deliberately inserted into code; this vulnerability is an unintentional coding error, not a hidden access mechanism.
Concept tested: Stack-based buffer overflow via unchecked strcpy usage
Source: https://learn.microsoft.com/en-us/windows/win32/secbp/avoiding-buffer-overruns
Topics
Community Discussion
No community discussion yet for this question.