Computer Security: Format String Vulnerabilities, Race Conditions, and Static Analysis

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

1/42

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:33 AM on 3/19/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

43 Terms

1
New cards

format string vulnerabilities

The problem stems from the use of unchecked user input as the format string parameter in certain C functions that perform formatting, such as printf()

2
New cards

How to exploit the format string vulnerabilities?

Exploit the possibility of memory leak - using x08 in previous examples will print more data from the stack until exhausting the entire stack (memory information leak)

3
New cards

race condition

A software bug that occurs when the behavior of a program depends on the timing or sequence of events that are not under the control of the program.

4
New cards

How to judge whether a given event is a race condition or not

Concurrency Property - At least two control flows execute concurrently

Shared Object Property - he concurrent flows must access a common shared object (race object)

Change State Property - At least one control flow must alter the state of the race object

5
New cards

Concurrency Property

At least two control flows execute concurrently

6
New cards

Shared Object Property

The concurrent flows must access a common shared object (race object)

7
New cards

Change State Property

At least one control flow must alter the state of the race object

8
New cards

security issuess of race conditions

Denial of Service, TOCTOU

9
New cards

How to mitigate race conditions

we should ensure race windows do not overlap by making them mutually exclusive (lock), Using synchronizations and atomic operations, No concurrency, Using immutable objects (not shared objects)

10
New cards

TOCTOU

when a program checks the state of a resource at one point in time, and then uses that resource based on that state at a later point in time, without checking the state of the resource again.

11
New cards

TOCTOU

Time of check to Time of Use

12
New cards

What is static analysis

Done through manual review, or through automated tools while the code is not running. McGraw Touchpoint 1:Code Review

13
New cards

What is the pros and cons for static analysis

Pro: Support a wide variety of static checks that may not be covered by the compiler itself

Con: "Partial verification"

14
New cards

tools for static analysis

CPPCheck, UNO Spinroot

15
New cards

specification

a set of documented requirements/conditions to be satisfied by a material, design, product, service, or program

16
New cards

hoare logic

A formal system with a set of logical rules for reasoning rigorously about the correctness of computer programs

17
New cards

What is hoare triple?

A triple describes how the execution of a piece of code changes the state of the computation

18
New cards

assertion

a statement that a predicate (Boolean-valued function, i.e. a true-false expression) is expected to always be true at that point in the code

19
New cards

post condition

f() is an assertion that holds when f() returns

20
New cards

pre-condition

f() is an assertion that must hold at input to f()

21
New cards

Partial Correctness

Doesn't always terminate or can terminate and is correct.

22
New cards

Total Correctness

Can always terminate and it is correct

23
New cards

symbolic execution

analyzing a program to determine what inputs cause each part of a program to execute

24
New cards

what is the difference between symbolic

execution and normal execution?

normal execution uses a concrete input value, symbolic uses a symbolic value that could take any value

25
New cards

What is the difference between symbolic execution and dynamic analysis

Dynamic analysis tests concrete inputs that Uusually execute one branch, Input-by-input, Simulate only one test run

Symbolic execution tests symbolic inputs, Execute all the branches/paths simultaneously, Path-by-path, When execute one path, we actually simulate many test runs, since we are considering all the

inputs that can exercise the same path

26
New cards

The tools for symbolic execution

KLEE

27
New cards

Empty statement axiom

{p} skip {p} - whatever holds true before skip also holds true afterwards

28
New cards

Assignment axiom

After the assignment, any predicate that was previously true for the right-hand side of the assignment now holds for the variable.

29
New cards

How to prove correctness of a program

Verify that, no matter how function is called, if precondition is met at function's entrance, then postcondition is guaranteed to hold upon function's return

30
New cards

UNO (SPIN) Stands for:

Uninitialized data, Nil-pointer dereferencing, Out-of-bound array indexing

31
New cards

CPPCheck

Automatic variable checking

Bounds checking for array overruns

Classes checking (e.g. unused functions, variable initialization and memory

duplication

Usage of deprecated / superseded functions

Exception safety checking, for example usage of memory allocation and destructor

checks

Memory leaks, resource leaks, etc.

32
New cards

Mitigation for TOCTOU?

Check again upon use, The program should use appropriate permissions and access controls to limit access to sensitive resources

33
New cards

Race window

a code segment that accesses the race object in a way that opens a window of opportunity for race condition

34
New cards

Synchronization primitives

used to ensure that a specific part of the program can't be executed by more than one thread at the same time.

35
New cards

Format Strings are used for

convert simple C data types to a string representation

36
New cards

%d

decimal

37
New cards

%u

unsigned decimal

38
New cards

%x

hexadecimal (unsigned int)

39
New cards

%s

string (const(unsigned)char *)

40
New cards

%n

number of bytes written so far

41
New cards

"%s%s%s%s%s" for a format string

For each %s, printf() will fetch a number from the stack, treat this number as an address, and print out the memory contents pointed by this address as a string, may also crash due to memory address not exisiting

42
New cards

Writing arbitary memory location

Read arbitrary memory location:

user_input = "\x08\x48\x01\x10%08x%08x%08x%08x%s"

What if the user_input is changed to:

user_input = "\x08\x48\x01\x10%08x%08x%08x%08x%n"

This allows to write arbitrary data to memory location 0x10014808

43
New cards

You've started learning these terms. Keep it up!

Explore top notes

note
Data Acquisition
Updated 1073d ago
0.0(0)
note
Oxidative Phosphorylation
Updated 1191d ago
0.0(0)
note
economics
Updated 416d ago
0.0(0)
note
Tools of Foreign Policy
Updated 1241d ago
0.0(0)
note
Art Notes - Sem 2 2024
Updated 507d ago
0.0(0)
note
Lord of the Flies
Updated 707d ago
0.0(0)
note
Data Acquisition
Updated 1073d ago
0.0(0)
note
Oxidative Phosphorylation
Updated 1191d ago
0.0(0)
note
economics
Updated 416d ago
0.0(0)
note
Tools of Foreign Policy
Updated 1241d ago
0.0(0)
note
Art Notes - Sem 2 2024
Updated 507d ago
0.0(0)
note
Lord of the Flies
Updated 707d ago
0.0(0)

Explore top flashcards

flashcards
Latin quiz 1 review
46
Updated 268d ago
0.0(0)
flashcards
GLW #2
20
Updated 180d ago
0.0(0)
flashcards
ETS RC 2023 - TEST 01 PART 5
130
Updated 913d ago
0.0(0)
flashcards
Unit 8: Clinical Psychology
64
Updated 1079d ago
0.0(0)
flashcards
APUSH Midterm
42
Updated 100d ago
0.0(0)
flashcards
Latin quiz 1 review
46
Updated 268d ago
0.0(0)
flashcards
GLW #2
20
Updated 180d ago
0.0(0)
flashcards
ETS RC 2023 - TEST 01 PART 5
130
Updated 913d ago
0.0(0)
flashcards
Unit 8: Clinical Psychology
64
Updated 1079d ago
0.0(0)
flashcards
APUSH Midterm
42
Updated 100d ago
0.0(0)