export PATH=$PATH:/YourHome/llvm37/build/Release+Asserts/bin
cd /YourHome/llvm37/build/lib/Transforms/AliasSets make cd /YourHome/llvm37/build/lib/Transforms/DepGraph make cd /YourHome/llvm37/build/lib/Transforms/bSSA2 makeYou have also to compile the xmlparser using the command below inside /YourHome/llvm37/lib/Transforms/bSSA2:
g++ -shared -o parserXML.so -fPIC parserXML.cpp tinyxml2.cppThe command above will create a file named parserXML.so. Move this file to /YourHome/llvm37/build/Release+Asserts/lib.
clang -emit-llvm -c -g monty.c -o monty.bc opt -instnamer -mem2reg monty.bc > monty.rbc opt -basicaa -load AliasSets.so -load DepGraph.so -load bSSA2.so -bssa2 -xmlfile in.xml monty.rbcMoreover, you can join several .c files in a single .bc using clang + llvm-link just like example bellow:
clang -emit-llvm -c -g main.c -o main.bc clang -emit-llvm -c -g foo.c -o foo.bc llvm-link foo.bc main.bc -o out.bcPlease, see that you must inform a xml file with the functions and respective parameters which you consider sensitive or secrete information. Below you can see an example of such an xml file. In this case, Flow Tracker will locate the function named fp_rdcn_var and it will consider the first and the second parameters as sensitive information. If the user specify the parameter 0, FlowTracker will consider the function's return value as a secret.
<functions> <sources> <function> <name>fp_rdcn_var</name> <parameter>1</parameter> <parameter>2</parameter> </function> </sources> </functions>If the target program contains a vulnerable trace, then Flow Tracker will create two files for each of those traces.
Tracking vulnerability for 'file monty.c line 298 to file monty.c line 181 ' monty.c 181 monty.c 181 monty.c 181 monty.c 246 monty.c 246 monty.c 246 monty.c 199 monty.c 199 monty.c 199 monty.c 199 monty.c 199 monty.c 199As we can see, the monty.c has a vulnerable trace that starts at line 298 and finishes at line 181. The following lines shows in backward way the entire vulnerable trace. We do not show the last line in the trace, only in the header description. Line 199 is the line that comes immediately before the start line 298 in our trace.
clang -emit-llvm -c -g monty.c -o monty.bc opt -instnamer -mem2reg monty.bc > monty.rbc opt -load AliasSets.so -load DepGraph.so -load hammock.so -load bSSA2.so -bssa2 -xmlfile in.xml monty.rbc
C-Src: the C program that we have analyzed. This is an actual program, i.e., the very input to our analyzer.
Full Dep Graph: the complete Dependence Graph with control edges and data edges. Each vertex is labeled with one operand or operator.
Tainted Sub Graph: the Dependence Graph which IS produced by our tool. This DFG has the respective line numbers from source file and is useful for developer to identify the vulnerability in the code. Note that the SUB-DFG is one example, however the tool can to produce more than one SUB-DFG if there exists several vulnerable paths. In red color is the shortest path which connects the secret to a branch instruction.
TXT-Lines: ASCII format of the path in red color presented at "Taited Sub Graph".
C-SRC |
FULL DEP GRAPH |
TAINTED SUB GRAPH |
TXT-Files |
XML |
COMMENTS |
ex1.c: this is an example of naive string matching algorithm. the function compvar does not execute at constant time because the return instruction inside the loop could ends the function before the last iteration for some inputs |
|||||
ex2.c: again, an example of naive string matching algorithm. the function compvar does not execute at constant time because the attribution of variable isequal could not be done for some input |
|||||
ex3.c: this is a good example of a function for string comparisson which runs in constant time and can be used in cryptosystem's implementation. of course, our tool did not found any vulnerable tainted subgraph in this example |
|||||
ex4.c: again, this example runs in constant time. of course we have a branch instruction, but it is not problematic because the loop runs for constant iterations and the cost of each iteration is the same. therefore our tool did not found any tainted subgraph in this example |
|||||
ex5.c: another example which the code runs in constant time. in this case the branch instruction for the while loop is influenced by information stored in the secret variable. however, again this loop runs all iteration and therefore the code is not dangerous. of course, our too did not found any problem with this code |
|||||
ex6.c: at this example, the number of instructions in both side of branch instruction (true and false) is the same. however the execution time could be non constant because architectural aspects like cache miss, speculative execution and the respective pipeline flush for instance. so, flow tracker informs a vulnerability at this code |
|||||
ex7.c: this example uses a ternary operator in order to make a test. llvm compiler translate this c code in such way that no branch instruction is generated. so, this example is safe because the translation is good |
|||||
ex8.c: here we have an example where a secret information is used to memory indexing. so, this code is vulnerable to a attack named cache-timing attack. the rule for avoiding cache-timing attacks is "avoid table look-ups indexed by secret data". that's the rule stated in http://cryptocoding.net. flow tracker can find this kind of vulnerability |
|||||
ex9.c: It is a tiny example showing that Flow Tracker is a inter-procedural analysis and It can get vulnerabilities inter-process. |
|||||
armandoExample1.c: Thanks to Armando from IC-Unicamp by this example. Flow Tracker can get its vulnerability as well. |
|||||
smult.c: is a implementation in constant time of eliptic curves diffie-hellman (curve25519). of course, the implementation is safe and flow tracker not found any vulnerability. |