Buffer Overflow Quiz

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/56

encourage image

There's no tags or description

Looks like no tags are added yet.

57 Terms

1
New cards

What is a buffer overflow?

A program writes data beyond the allocated size of a buffer.

2
New cards

What is the text segment?

Stores the program's executable instructions.

3
New cards

What is the data segment?

Holds global and static variables.

4
New cards

What is the BSS segment?

Stores global and static variables initialized to zero or without explicit initialization.

5
New cards

What does BSS stand for?

Block Started by Symbol.

6
New cards

What is stored on the stack?

Function calls, local variables, function parameters, and return addresses.

7
New cards

What is the heap used for?

Dynamic memory allocation, such as malloc().

8
New cards

Where are global variables stored?

Data segment.

9
New cards

Where are uninitialized static variables stored?

BSS segment.

10
New cards

Where are local variables stored?

Stack.

11
New cards

Where is dynamically allocated memory stored?

Heap.

12
New cards

What is a stack-based buffer overflow?

An overflow that can overwrite stack data, including return addresses.

13
New cards

What is a heap-based buffer overflow?

An overflow that can corrupt data in adjacent memory blocks.

14
New cards

What can a data/BSS overflow overwrite?

Global variables and potentially important program data or configurations.

15
New cards

What is a stack frame?

The stack area associated with a function call.

16
New cards

What is the purpose of a return address?

Identifies where execution continues after a function returns.

17
New cards

What is the frame pointer (EBP) used for?

References local variables and function arguments in a stack frame.

18
New cards

In what order are function arguments pushed onto the stack, according to the slides?

In reverse order.

19
New cards

What can happen if a return address is overwritten?

Execution may jump to an invalid address or attacker-controlled code.

20
New cards

What is gets() dangerous?

It reads input without checking the buffer's size.

21
New cards

What should be used instead of gets()?

fgets().

22
New cards

What does strcpy(dest, src) do?

Copies a string from src to dest.

23
New cards

Why is strcpy() dangerous?

It can keep writing when the source string is longer than the destination buffer.

24
New cards

What should be used instead of strcpy()?

strncpy().

25
New cards

What does strcat(dest, src) do?

Appends a string to the destination string.

26
New cards

Why is strcat() dangerous?

The combined strings may exceed the destination buffer's capacity.

27
New cards

What should be used instead of strcat()?

strncat().

28
New cards

Why can scanf() be dangerous?

Some options do not limit the maximum input length.

29
New cards

Why is scanf("%s", buffer) without a width limit risky?

Input can exceed the buffer's capacity.

30
New cards

What is shellcode?

Assembly or machine instructions used to launch a shell.

31
New cards

What does execve() do?

Executes a program and replaces the current process image with the new program.

32
New cards

What does a NOP instruction do?

Does nothing.

33
New cards

Why can zero bytes cause a shellcode problem?

strcpy() stops copying when it encounters a zero byte.

34
New cards

What is ASLR?

Address Space Layout Randomization.

35
New cards

What is the purpose of ASLR?

Makes memory addresses harder to predict by randomizing their locations.

36
New cards

What does ASLR setting 0 mean in the slides?

Address space is not randomized.

37
New cards

What does ASLR setting 1 mean in the slides?

Only stack memory addresses are randomized.

38
New cards

What does ASLR setting 2 mean in the slides?

Both stack and heap memory addresses are randomized.

39
New cards

What is the NX bit?

A feature that marks certain memory areas as non-executable.

40
New cards

What is StackGuard?

A compiler-based protection that checks a canary to detect stack corruption.

41
New cards

What does -fstack-protector do?

Adds code during compilation to protect against stack overflows.

42
New cards

What does -D_FORTIFY_SOURCE=2 do?

Replaces some memory and string functions with bounds-checking versions.

43
New cards

What are the developer-level countermeasures in the slides?

Use safer functions such as strncpy() and strncat().

44
New cards

What is CWE?

Common Weakness Enumeration, a list of software security weaknesses.

45
New cards

What is CWE-118?

Improper access of an indexable resource (range error).

46
New cards

What is CWE-119?

Improper restriction of operations within memory-buffer bounds.

47
New cards

What is CWE-120?

Buffer copy without checking input size (classic buffer overflow).

48
New cards

What is CWE-121?

Stack-based buffer overflow.

49
New cards

What is CWE-122?

Heap-based buffer overflow.

50
New cards

What is CWE-125?

Out-of-bounds read.

51
New cards

What is CWE-134?

Uncontrolled format string.

52
New cards

What is CWE-787?

Out-of-bounds write.

53
New cards

What is a format string attack?

An attack in which an attacker controls a formatting string used by functions such as printf() or scanf().

54
New cards

What can an attacker gain from a format string attack?

They may expose secret data or cause excessive output or buffer overflows.

55
New cards

What is a double-free error?

Calling a free operation on the same argument more than once.

56
New cards

Which languages are identified as especially common for buffer overflows?

C, C++, and Objective-C.

57
New cards

How can buffer overflows affect a program?

They can cause crashes, corrupt data, or allow an attacker to control execution