Comp Security- Week 5a Flashcards
When does a format string vulnerability occur?
When a formatted I/O function expects more arguments than are provided
%d output type and passed as?
decimal. passed as value
%u output type and passed as?
unsigned decimal. passed as value
%x output type and passed as?
hexadecimal. passed as value
%s output type and passed as?
string. passed as reference
%n output type and passed as?
number of bytes written so far, passed as reference
Why is printf(buf) a sloppy use of printf function. And can a format string attack occur
sloppy use because format parameter is not written here.
No a format string attack cant occur because buf is not an input from the user however if they were to ask user to enter value of a variable and the correct format isnt followed a problem will occur
Printf is a function so when its called what will be created?
a stack
What is the first thing to be pushed in stack?
the arguments
The first argument is always.. followed by…
The first argument is always the format string then followed by the specified arguments
What happens if the programmer doesnt put the format string
Then printf will print even if we put variables and the attacker can benefit from this
Format string attacks allow..
- Read data from the stack from an illegal address causing program to crash (DOS)
- Overwrite memory to change program execution or force execution of user supplied code
- Access memory and extract confidential data
What can an intruder do if he has control of the format string?
Read items in memory by using %x
Write items in memory by using %n (write to memory location after arg1)
what happens if someone writes foobar%n
The num of characters in foobar=6 so that is the number of bytes that will be written to that location
The program will attempt to write the number 6 to the address
This will result in an error message and the memory wont be written and it will crash which will prove its exploitable
when one could write to memory what are they able to do
With this ability they could overwrite a return pointer redirecting the execution path to the injected code