1/52
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What is a major advantage of using C?
C is a small language that is close to the hardware, allowing for highly efficient code.
What is a major disadvantage of using C/C++?
Using C/C++ can be dangerous due to vulnerabilities like buffer overflows.
What happens if you write to an out-of-bounds index in an array in C?
It results in undefined behavior, which can lead to security vulnerabilities.
What is the primary security issue associated with C/C++?
Buffer overflow is the number one security issue in software.
What should be done to prevent buffer overflow vulnerabilities?
Check array bounds at runtime.
Why have C and C++ not adopted array boundary checks?
For efficiency reasons.
What types of code are particularly vulnerable to buffer overflows?
Code handling untrusted input, such as network input and user input. Embedded software and untrusted files
What function should never be used due to buffer overflow risks?
The gets() function.
What is a safer alternative to gets()?
fgets(buf, size, stdin).
What is the risk associated with the strcpy() function?
It assumes the destination buffer is large enough, which can lead to overflow.
What is a safer alternative to strcpy()?
Use strncpy(dest, src, size) instead.
What is the difference between strcat() and strncat()?
strcat() appends the entire second string, while strncat() appends a specified number of characters.
What can happen if you use the wrong size argument in strncat()?
It can lead to buffer overflow if the size exceeds the buffer's capacity.
What is a common mistake when using strncpy()?
Not ensuring the destination is null-terminated after copying.
What is an implicit casting bug?
It occurs when a signed integer is implicitly cast to an unsigned integer, leading to unexpected behavior.
What is a format string vulnerability?
It occurs when user-controlled input is passed to a format function, allowing arbitrary memory access.
How can format string vulnerabilities be prevented?
Avoid user-controlled format strings and validate/sanitize all user inputs. Use explicit format strings, limited permissions, and static code analysis
What is the risk of using printf with user-controlled input?
It can lead to security breaches and system compromise.
What is a potential consequence of a buffer overflow in server code?
It can crash the server or allow an attacker to execute arbitrary code.
What should be done if the length of user input is unknown?
Always validate and check the length before processing.
What can happen if a negative length is used in malloc()?
It can lead to over-allocation or failure, resulting in buffer overflow.
What is the maximum value for a signed short integer?
32767 (2^15 - 1).
What is the significance of the null terminator in C strings?
It indicates the end of the string and is crucial for proper string handling.
What is the output of printf if the input is improperly formatted?
It may lead to printing unintended memory addresses or cause crashes.
What is the purpose of validating user input?
To prevent vulnerabilities such as buffer overflows and format string attacks.
What is a common mistake when calculating buffer sizes?
Using the wrong size argument, which can lead to buffer overflow.
What should be done to user inputs before using them in format functions?
Validate and sanitize all user inputs.
What is a safer way to use user input in format strings?
Use explicit format strings, e.g., printf("%s", userInput).
What is one method to minimize the impact of successful attacks?
Ensure that the process running the code has limited permissions.
What tool can be used to detect potential format string vulnerabilities?
Static code analysis tools.
What is a fundamental solution for preventing buffer overflow attacks?
Array bounds checking.
What is the purpose of making memory segments non-executable?
To prevent attackers from executing malicious code injected into stack or heap.
What compiler option can be used to mark the stack segment as non-executable?
-z noexecstack.
What is a canary word in the context of StackGuard?
A canary word is placed before each return address in a stack frame to detect buffer overflows.
What does RAD stand for in buffer overflow prevention?
Return Address Defender.
What is the role of a type-safe language in preventing buffer overflows?
Type-safe languages automatically enforce array bounds checking.
What is a weakness of using type-safe languages?
Most existing software is not written in type-safe languages.
What is anomaly detection used for in cybersecurity?
To identify data patterns that deviate from the norm, signaling potential security threats.
What does ASLR stand for?
Address Space Layout Randomization.
What is the purpose of ASLR?
To randomize the memory locations of key process components to make it harder for attackers.
What is one weakness of code randomization?
Performance overhead and the assumption that most attacks are code injection attacks.
What is memory address obfuscation?
A technique that randomizes the base addresses of various memory regions to complicate attacks.
What can be introduced to create random-length gaps in memory?
Padding in stack frames and between malloc allocations.
What is a common weakness of static source code analysis?
It can produce false positives and false negatives.
What is the main purpose of using safe C library functions?
To prevent buffer overflows by checking buffer boundaries.
What is a potential issue with using strcpy and strcat?
They do not check the buffer boundaries of destination buffers.
What happens when a buffer overflow attack is launched?
The return address and possibly the canary word are overwritten.
What is the role of StackGuard in buffer overflow prevention?
To protect against stack smashing by verifying the integrity of canary words.
What is a weakness of the RAD approach?
It only protects return addresses.
What is the effect of making segments of memory non-executable?
It prevents the execution of malicious code in those segments.
What is the main challenge of rewriting legacy code in type-safe languages?
The scale and complexity involved in the existing software.
What is a common method to detect unusual activities in cybersecurity?
Anomaly detection.
What does the NX bit do?
It helps the OS manage execution permissions for memory segments.