UAFPrediction is a tool which uses the Support Vector Machine learning model to determine the likelihood of a use-after-free bug within C source files.
There are numerous C static bug detectors which aim to locate the existance of use-after-free bugs, though not all tools are perfect and there are some limitations when utilising static analysis such as filtering false positives
This tool requires
- python3 installed and the python modules Scikit-learn and its associated dependencies
- CBMC tool: http://www.cprover.org/cbmc/
- Coccinelle tool http://coccinelle.lip6.fr/download.php
- Clang 3.8 http://releases.llvm.org/download.html
- SVF tool https://github.com/yuleisui/SVF
Modify coccinelle.py, cbmc.py and stc.py to show where coccinelle, cbmc and SVF is installed on your system.
- On line 6, modify
cocci_loc
to where Coccinelle is invoked on your system. If you have install Coccinelle using a package manager, the default invocation isspatch
. - On line 7, modify
uaf_cocci_loc
to where the uaf.cocci file is located on your system. The uaf.cocci file is apart of the git repository.
- On line 6, modify
cbmc_loc
to where CBMC is invoked on your system. If you have installed CBMC using a package manager, the default invocation iscbmc
.
- On line 7, modify
clang_loc
to where the LLVM Clang 3.8 compiler is invoked on your system. - On line 9, modify
stc_loc
to where the SVF binary is located on your system.
- Invoke the UAFPrediction.py program using python3 from the base folder of where C source files are located.
- After execution the tool will report if a Use-After-Free bug has been predicted. If a bug has been predicted, then the output of the tools will be report. Otherwise the message “No Use-After-Free bugs have been predicted” message will appear.
Under the test folder, there are some examples to showcase the program in action.
- To use the CWE416_Use_After_Free__return_freed_ptr_18_bad.c test case, it must be called with io.c.
- e.g. python3 /path/to/UAFPrediction.py CWE416_Use_After_Free__return_freed_ptr_18_bad.c io.c