Give two reasons as to why buffer overflow attacks are still problematic
- Careless programming
Explain the “basics” of buffer overflow, why it is possible and how it works on the memory-level
Give some examples of differences between C and Python, with regards to buffer overflow
• C/C++
o Have high-level control structures
o But allow direct access to memory, hence are vulnerable to buffer overflow
• Java / Python / ML / Modern high-level languages
o Have a strong notion of type and valid operations
o Not vulnerable to buffer overflows
o Utilizes garbage collectors
o Has overhead, some limits on use
Give some examples of ways in which an attacker can find opportunities for buffer overflow attacks
♣ Source code inspection (e.g. on GitHub log)
♣ Binary code inspection
♣ Tracing execution
♣ Fuzzing tools (random inputs)
Explain what a “Stack Buffer overflow” is, and how it works
Explain what a “Return attack” is, one prerequisite for the attacker in order for it to work, and how the attack works
• Attacker needs o Know where the function is loaded ♣ (the address is used to override the return pointer) ♣ use debugger o know space below the frame pointer ♣ inspection o know valid value for overwriting frame pointer o consider little-Endian vs big-Endian
Give some examples of possible effects of a “buffer overflow” attack
Explain what “Shellcode” is, in the context of “Buffer overflow” attacks
• Code supplied by attacker
o Often saved in buffer that is overflowed
o Traditionally transfer control to a shell
Explain what “Global data overflow” is, and briefly describe some of its features
Explain what “Heap overflow” is, how it works, and shortly describe why it’s possible
Explain what “Return to System Call” attack is, and how it works
Explain what “Return Oriented Programming” attacks are, and how they work
Explain what “Code reuse” attacks are, and how they work
What are “dangling pointers”, and how can they occur?
• Dangling pointers: do not point to a valid object of the appropriate type
o Wrong dynamic cast of pointers
o Missing update of pointers when memory is released (explicitly with free, implicitly by destroying the stack frame)
o Missing initialization of pointers
Explain what an “Arithmetic Overflow” is, and some possible effects of it
• An integer, which has not been properly checked, is incremented past the maximum possible value
• It may wrap to become a very small, or negative number
• Can lead to buffer overflows, if the integer is used to compute memory offsets, array indexes etc.
Can lead to violation of security policies
• Can lead to failures
• Can lead to data corruption
Give some examples of countermeasures to prevent “Arithmetic overflow”
Explain what “Virtual Memory” is
Explain how operating systems use virtual memory to function
- Memory divided in pages o Page tables sets memory attributes per page - OS configures Virtual Memory o Isolates processes o Mediate communications o Mediate access to HW and File System - OS executes in privileged mode o All other processes are executed unprivileged
What are the possible effects of “buffer overflow”, remembered by the rule of thumb: “SDCVX”?
Give some examples of “Compile-time defenses” against buffer overflow
Describe how programming language can be used to defend against buffer overflow attacks
SDCVX
Describe how “safe coding” can be used to defend against buffer overflow attacks
SDCVX
Explain what “Verification” is, in the context of writing code, how it works, one reason why it isn’t always used, and give an example of where it often is used
• Code verification o Using mathematical model o Proving absence of bugs • Expensive: ~ $2000 per line of code • Verified execution platforms o Isolation kernels o Software fault isolation
Describe how “Language extension” and “Safe libraries” can be used to defend against buffer overflow attacks, and what some drawbacks are
o Performance penalties
o Must compile programs with special compilers
SDCVX