Closed wmkhoo closed 6 years ago
Thanks @GiuseppeDiGuglielmo
Running this test case with
valgrind --tool=taintgrind -- taintgrind/tests/misprint 12 134513924
gives me this output
0x8048615: main (misprint.c:45) | STORE t18_10366 = t14_7982 | 0x8048504 | 0xffffffff | canary <- t14_7982
...
0x8048623: main (misprint.c:44) | t55_450 = LOAD I32 t53_1077 | 0x8048504 | 0xffffffff | t55_450 <- val
...
0x8048615: main (misprint.c:45) | STORE t59_291 = t55_450 | 0x8048504 | 0xffffffff | func <- t55_450
...
0x8048625: main (misprint.c:52) | t5_11953 = LOAD I32 t3_7605 | 0x8048504 | 0xffffffff | t5_11953 <- func
0x8048628: main (misprint.c:52) | JMP t5_11953 | 0x8048504 | 0xffffffff | t5_11953
It's quite hard to tell, but the jump target at line 52 is tainted. Taint flows from value to func to the jump. Not sure why it crashes. You're running CentOS?
You can generate the taint graph by running:
valgrind --tool=taintgrind -- taintgrind/tests/misprint 12 134513924 2>&1 | python taintgrind/log2dot.py | tee misprint.dot
dot -Tpng misprint.dot -o misprint.png
The taint graph is equally hard to tell, but I tried to highlight the tainted jump in red.
Created wiki page for this: Detecting a classic buffer overflow
I am trying to use Taintgrind for Dynamic Information Flow Tracking in the context of buffer overrun attacks.
A classical example would be:
If I compile the application:
$ cc -g -O0 -fno-inline -fno-omit-frame-pointer -fno-stack-protector -m32 misprint.c -o misprint
And run it with "safe" parameters, it simply prints Hello World.
If I run it with parameters that lead to a buffer overrun attack (you may have to find the pointer to the secret function):
Now I am trying to figuring out if Valgrind + Taintgrind can allow me to intercept the attack. I would like to propagate the tag to the "secret function" call.
But, for the moment I get a SIGSEGV process termination (segfault).
Is there a way to perform DIFT (Dynamic Information Flow Track) with Taintgrind? Credit: Giuseppe Di Guglielmo