You are currently viewing a new version of our website. To view the old version click .
Sustainability
  • Article
  • Open Access

21 May 2018

An Automated Vulnerability Detection and Remediation Method for Software Security

,
and
Korea Internet & Security Agency, 9, Jinheung-gil, Naju-si, Jeollanam-do 58324, Korea
*
Author to whom correspondence should be addressed.
This article belongs to the Collection Advanced IT based Future Sustainable Computing

Abstract

As hacking techniques become more sophisticated, vulnerabilities have been gradually increasing. Between 2010 and 2015, around 80,000 vulnerabilities were newly registered in the CVE (Common Vulnerability Enumeration), and the number of vulnerabilities has continued to rise. While the number of vulnerabilities is increasing rapidly, the response to them relies on manual analysis, resulting in a slow response speed. It is necessary to develop techniques that can detect and patch vulnerabilities automatically. This paper introduces a trend of techniques and tools related to automated vulnerability detection and remediation. We propose an automated vulnerability detection method based on binary complexity analysis to prevent a zero-day attack. We also introduce an automatic patch generation method through PLT/GOT table modification to respond to zero-day vulnerabilities.

1. Introduction

The number of vulnerabilities is increasing rapidly due to the development of new hacking techniques. Between 2010 and 2015, around 80,000 vulnerabilities were newly registered in the major database known as the CVE (Common Vulnerability Enumeration) [1]. In recent years, the scope of security threats has also been expanded; i.e., IoT [2], Cloud [3], etc. The number of zero-day vulnerabilities has soared to the point that specialists can no longer be relied upon to respond to vulnerabilities. In order to respond quickly to a zero-day attack, automated vulnerability detection and automatic patching processes are necessary. In this paper, we propose a technology that performs fuzzing and symbolic execution based on binary complexity to automatically detect vulnerabilities. In addition, we propose an automatic patching technique to modify the GOT/PLT table to patch binary for a quick response to the attack of an automated vulnerability detection. In Section 2, we analyze trends and techniques for automated vulnerability detection and automated vulnerability remediation. In Section 3, we introduce our method that automatically detects vulnerability using a hybrid fuzzing based on binary complexity analysis and automatic patch vulnerability by loading a safe library through the GOT/PLT table modification. In Section 4, our experimental results are presented. Finally, in Section 5, we discuss our conclusion and future work.

3. Automated Vulnerability Detection and Remediation Method

Fuzzing works much faster than symbolic execution and is capable of exploring a deeper range of code depths. However, it is difficult for a fuzzer to explore widespread code. Symbolic execution can discover possible paths of the program, but exploring is limited due to path explosion with an explosive number of paths. Many types of hybrid fuzzers are available to complement these mutual strengths and weaknesses. However, most hybrid fuzzers choose a vulnerability detection engine without analyzing the target program. A program has complex parts such as loops and recursions that are hard to explore, but some parts of the program are simply reachable. Accordingly, it is possible to identify which parts are advantageous for fuzzing or symbolic execution. In this paper, we introduce a binary analysis method to identify the advantageous areas for fuzzing and symbolic execution, as shown in Figure 1.
Figure 1. Automated Vulnerability Detection and Remediation Architecture.
Hybrid fuzzing based on binary analysis selects fuzzing and symbolic execution through binary complexity metrics. Using the selected vulnerability search engine, it creates a new seed that causes a state transition. The newly created seed is used to analyze the binary complexity again and repeats the same process. Hybrid fuzzing based on a binary analysis will then proceed to the next five steps:
  • Seed Selection: Seed selection is a step to select the input value to be used for vulnerability detection. In a first iteration, a seed scheduler selects a seed defined by the user to detect vulnerability. From a second iteration, a new seed created by the seed generation engine is selected for the next step.
  • Binary Analysis: A binary analysis module executes the target binary in an instrumentation environment. As a binary is executed, disassembly code and function call information are extracted through binary instrumentation. Binary complexity and vulnerability scores are analyzed using the extracted information. The results of the complexity analysis determine whether to run a fuzzer or symbolic executor to detect vulnerabilities. The results of the vulnerability score will be used to determine whether a detected crash is exploitable in future research.
  • Engine Selection: The engine selection module chooses one of the fuzzing and symbolic execution engines according to the result of the complexity analysis. The symbolic execution engine is executed if the complexity analysis result is smaller than a specific threshold; otherwise, the fuzzing engine is selected.
  • Seed Generation: The fuzzer or symbolic executor is executed to generate seeds to be used in the next iteration. The seed generation process is performed until a state transition occurs. When a state transition occurs, the seed value that caused the state transition is stored in the seed DB.
  • Repeat.
For automated vulnerability remediation, the vulnerable function-based patch technique is utilized to create a weak function list and modify the PLT/GOT with respect to the corresponding functions, to induce a call to a safe function. This is an application of the mechanism of lazy binding that the binary performs as a dynamic linking method to use a shared library. In addition, as shown in Table 3, the vulnerable function list is composed of 50 functions that can cause each of the four types of vulnerability, such as buffer overflow, format string, race condition, and multiple command execution.
Table 3. List of Vulnerable Functions by Vulnerability Type.

3.1. Binary Analysis

3.1.1. Instrumentation

To extract binary information, we leveraged a QEMU instrumentation tool [23]. QEMU is a virtualization tool that is often used for binary dynamic analysis. QEMU produces a TCG (tiny code generator) that converts binary code to IL (intermediate language). After converting, QEMU inserts a shadow value at the IL to extract the information we want to analyze. We utilize this instrumentation function to obtain disassembly code information and function call information.

3.1.2. Complexity Analysis

We utilized the Halstead complexity metrics to analyze binary complexity. The metrics were published in 1977 by Maurice Howard Halstead [24]. The metrics are intended to determine the relationship between measurable properties and Software Complexity. The metrics were originally developed to measure the complexity of the source code, but we applied it to measure the complexity of the assembly code. We analyzed the binary complexity by measuring the number of operators and operands in the assembly code using the metrics in Table 4.
Table 4. Halstead Complexity Metrics.

3.1.3. Vulnerability Scoring

When executing the binary, it traces all the function calls of the executed path. In the traced function calls, we check whether a function from the vulnerable functions shown in Table 5 is called. We assigned a vulnerability score separately for dangerous functions and banned functions as shown in Table 5. The number of a called function, which is defined as a dangerous function, is shown in Table 5. We accumulate scores whenever a dangerous function or a banned function is called. We refer to research on detecting vulnerabilities through software complexity and vulnerability scoring [25]. We are planning to extend this research to automatic exploit generation and automatic patch generation.
Table 5. Functions for Vulnerability Scoring.

3.2. Engine Selection

The Engine Selection Module choose between the fuzzing and symbolic execution engine through a complexity analysis of the target binary. For the complexity analysis, the user defined the threshold value and put this value as an input of the engine selection. The number of operators, number of operands, total operators, and total operands extracted from dynamic binary instrumentation are used to measure program difficulty. If the program difficulty is lower than the threshold, the engine selection module chooses the symbolic executor. If not, the fuzzer is selected. The algorithm for the vulnerability detection engine selection is as follows.
Algorithm: Selection of Vulnerability Detection Engine
Input: Threshold T
Data: Difficulty D, n 1 , n 2 , N 1 , N 2
Result: Seed S
function Engine Selection(T);
begin
  D ← Complexity ( n 1 , n 2 , N 1 , N 2 );
  if D < T then
    S ← Symbolic Executor();
  else
    S ← Fuzzer();
end
return S;
end

3.3. Fuzzing

We used AFL (American Fuzzy Lop), which is an evolutionary fuzzer using a genetic algorithm. AFL performs fuzzing in three main steps. First, the AFL mutates the seed value with various bit mutation strategies (e.g., interest bit flip, subtract/add bit flip). Second, the AFL continues to monitor the execution status and records the state transition to expand code coverage. Third, the AFL trims parts that do not affect the state transition to minimize the range of mutation. By repeating the above three steps, the input value is developed in the direction of the state transition. We did not modify the core engine of the AFL Fuzzer and considered only its coordination with the symbolic executor. The Fuzzer operates when the binary analysis result is greater than the threshold.

3.4. Symbolic Execution

The Angr tool was used for Symbolic Execution. Angr utilizes Valgrind’s VEX IR to build a symbolic execution environment. SimuVEX, which is a VEX IR emulator, produces an environment to execute a symbolic state translated from binary through VEX IR. If the branch statement is encountered while executing binary, the path predicate for the branch is generated and the z3 solver tries to solve the constraint in the path predicate. Angr also provides various functions for analyzing the control flow graph. The main function is backward slicing, which helps to locate the source of a variable on a program slice. We will develop this backward slicing function to find the root cause of a vulnerability. It produces two methods to recover the control flow graph. We did not modify the symbolic execution engine. The symbolic executor operates when the binary analysis result is less than the threshold.

3.5. Automatic Binary Patch

The execution file of the Linux environment is the ELF (Executable and Linkable File) format. The structure of the ELF file is briefly shown in Figure 2, of which the text section contains the code necessary for execution. In this section, the code is the main () function and is the initialization for configuring the execution environment, consisting of argc/argv argument processing, stack setting, library loading for normal execution of the main () function, and the termination processing code.
Figure 2. ELF file structure modification.
Replacing the constructor area of the binary with the secure library loader (secure_libs_loader) ensures that GOT can be changed before the main () function calls the weak function. The role of the loader is to ultimately load libsecu.so, which is a safe library in the same memory space as binary. The loader finds the address of the first dlopen () function as shown in Figure 3, and loads libsecu.so in the memory. After libsecu.so is loaded, the loader calls a function that performs a PLT/GOT patch within the library.
Figure 3. Secure_libs_loader operation process.
All processes occur before the main () function is executed. Therefore, the patch process accesses the GOT via the PLT of the vulnerability function to which the actual address is not yet bound. Since it has never been called, the patch is executed by overwriting the GOT of the vulnerable function with the address for the binding (usually PLT + 6 location) with the address of the safe function.
This technique is aimed at minimizing binary modification and indirectly replacing vulnerable functions with safe functions. In other words, it is necessary to modify the constructor in order to load the library of the binary circle, but there is no need to worry about the side-effects, such as destroying the original program without touching other code parts. In addition, since the loaded library is in the form of a shared library, it can be maintained and repaired independently. IoT devices such as smart phones and smart TVs based on Linux are more likely to be applied as targets, therefore flexibility and scalability can be expected.

4. Experimental Results

4.1. CFG Recovery Analysis

CFG recovery analysis is often used for the static analysis of vulnerabilities. Among the CFG recovery techniques, backward slicing is useful for root cause analysis because it extracts the only path information in which the binary is executed. We have a plan to utilize this analysis method to analyze the root cause of vulnerability. For benchmarking, we compared CFG recovery speed with the following tools, shown in Table 6, targeting 131 species of CGC challenge binaries [26]. We compared these tools on a server with a 3.60 GHz Intel Core i7-4960X 2 CPU and 4 GB of RAM. The backward slicing tool was slowest because of resource consumption, and the fastest tool was BAP with 1.63 s.
Table 6. CFG Recovery speed comparison.

4.2. Binary Patch Result

We used a Peach Fuzzer to trigger crashes of the open source software and compared the number of crashes before and after applying the patches in order to evaluate how many crashes we can eliminate through the automatic patch method. We chose eight open sources that were selected in descending order of the number of published vulnerability reports. We evaluated our method on a server with a 2.30 GHz Intel (R) Xeon E5-2650v3 CPU and 64 GB of RAM. The vulnerable functions shown in Table 7 were converted to safe functions by safe library loading. Let B be the number of crashes before the patch, and A be the number of crashes after the patch. The method of measuring the crash removal rate was evaluated as R as shown in the following equation.
R(%) = (B − A)/B × 100
Table 7. Comparison before and after patch.
As a result, the average vulnerability removal rate was 59%, and the vulnerabilities of 25% binaries were completely removed by automatic patch.

5. Conclusions

The number of vulnerabilities is increasing rapidly due to the development of new hacking techniques. However, time-consuming software analysis depending on a vulnerability analyst make it difficult to respond to attacks immediately. We proposed a method of Hybrid Fuzzing based on a binary complexity analysis. We also introduced an automated patch technique that modifies the PLT/GOT table to translate vulnerable functions into safe functions. The proposed model removed an average of 59% of crashes in eight open-source binaries, and 100% in two binaries. Because a 100% removal rate of crashes means that they are not exploitable, the result is significant, which means that a hacker cannot attack any more. With these results, we can respond more quickly to hacker attacks without the help of experts.
As a subject of future study, we will study automatic exploit generation to verify the patched binary and root cause analysis of vulnerability to patch vulnerable parts directly. We will also research the automatic classification of vulnerabilities by modeling various data mining techniques [27,28] and machine learning techniques [29,30].

Author Contributions

J.J. designed the system and performed the experiments; T.K. contributed to study design; H.K. help revise paper.

Acknowledgments

This work was supported by Institute for Information & communications Technology Promotion (IITP) grant funded by the Korea government (MSIT) (No. 2017-0-00184, Self-Learning Cyber Immune Technology Development).

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. U.S. National Vulnerability Database. Available online: http://cve.mitre.org/cve/ (accessed on 4 April 2018).
  2. Kang, W.M.; Moon, S.Y.; Park, J.H. An enhanced security framework for home appliances in smart home. Hum.-Centric Comput. Inf. Sci. 2017, 7, 6. [Google Scholar] [CrossRef]
  3. Keegan, N.; Ji, S.Y.; Chaudhary, A.; Concolato, C.; Yu, B.; Jeong, D.H. A survey of cloud-based network intrusion detection analysis. Hum.-Centric Comput. Inf. Sci. 2016, 6, 19. [Google Scholar] [CrossRef]
  4. Miller, B.P.; Fredriksen, L.; So, B. An empirical study of the reliability of UNIX utilities. Commun. ACM 1990, 33, 32–44. [Google Scholar] [CrossRef]
  5. Zzuf—Caca Labs. Available online: http://caca.zoy.org/wiki/zzuf (accessed on 4 April 2018).
  6. Peach Fuzzer. Available online: https://www.peach.tech/ (accessed on 4 April 2018).
  7. Sulley. Available online: https://github.com/OpenRCE/sulley (accessed on 4 April 2018).
  8. Aitel, D. An introduction to SPIKE, the fuzzer creation kit. In Proceedings of the BlackHat USA Conference, Las Vegas, NV, USA, 29 July–1 August 2002. [Google Scholar]
  9. Bekrar, S.; Bekrar, C.; Groz, R.; Mounier, L. A taint based approach for smart fuzzing. In Proceedings of the IEEE Fifth International Conference on Software Testing, Verification and Validation, Montreal, QC, Canada, 17–21 April 2012; pp. 818–825. [Google Scholar]
  10. American Fuzzy Lop. Available online: http://lcamtuf.coredump.cx/afl/ (accessed on 4 April 2018).
  11. Honggfuzz. Available online: https://github.com/google/honggfuzz (accessed on 4 April 2018).
  12. King, J.C. Symbolic execution and program testing. Commun. ACM 1976, 19, 385–394. [Google Scholar] [CrossRef]
  13. Godefroid, P.; Levin, M.Y.; Molnar, D.A. Automated whitebox fuzz testing. NDSS 2008, 8, 151–166. [Google Scholar]
  14. Cadar, C.; Dunbar, D.; Engler, D.R. KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs. OSDI 2008, 8, 209–224. [Google Scholar]
  15. Ciortea, L.; Zamfir, C.; Bucur, S.; Chipounov, V.; Candea, G. Cloud9: A software testing service. ACM SIGOPS Oper. Syst. Rev. 2010, 43, 5–10. [Google Scholar] [CrossRef]
  16. Cha, S.K.; Avgerinos, T.; Rebert, A.; Brumley, D. Unleashing mayhem on binary code. In Proceedings of the IEEE Symposium on Security and Privacy, San Francisco, CA, USA, 20–23 May 2012; pp. 380–394. [Google Scholar]
  17. Stephens, N.; Grosen, J.; Salls, C.; Dutcher, A.; Wang, R.; Corbetta, J.; Shoshitaishvili, Y.; Kruegel, C.; Vigna, G. Driller: Augmenting Fuzzing through Selective Symbolic Execution. NDSS 2016, 16, 1–16. [Google Scholar]
  18. Shoshitaishvili, Y.; Wang, R.; Salls, C.; Stephens, N.; Polino, M.; Dutcher, A.; Grosen, J.; Feng, S.; Hauser, C.; Kruegel, C. Sok: (State of) the art of war: Offensive techniques in binary analysis. In Proceedings of the IEEE Symposium on Security and Privacy, San Jose, CA, USA, 22–26 May 2016; pp. 138–157. [Google Scholar]
  19. Chipounov, V.; Kuznetsov, V.; Candea, G. S2E: A Platform for In-Vivo Multi-Path Analysis of Software Systems. In Proceedings of the Architectural Support for Programming Langugaes and Operating Systems, Newport Beach, CA, USA, 5–11 March 2011; pp. 265–278. [Google Scholar]
  20. Stephanie, F.; Thanh, V.N.; Westley, W.; Claire, L.G. A Genetic Programming Approach to, Automated Software Repair. In Proceedings of the 11th Annual Conference on Genetic and Evolutionary Computationm, Montreal, QC, Canada, 8–12 July 2009; pp. 947–954. [Google Scholar]
  21. Liu, C.; Yang, J.; Tan, L.; Hafiz, M. R2Fix: Automatically generating bug fixes from bug reports. In Proceedings of the International Conference on Software Testing, Verification and Validation, Luxembourg, 18–22 March 2013; pp. 282–291. [Google Scholar]
  22. Kim, D.; Nam, J.; Song, J.; Kim, S. Automatic patch generation learned from human-written patches. In Proceedings of the International Conference on Software Engineering, San Francisco, CA, USA, 18–26 May 2013; pp. 802–811. [Google Scholar]
  23. QEMU. Available online: https://www.qemu.org/ (accessed on 4 April 2018).
  24. Halstead, M.H. Elements of Software Science; Elsevier North-Holland: New York, NY, USA, 1977; p. 128. [Google Scholar]
  25. DARPA Cyber Grand Challenge. Available online: http://archive.darpa.mil/cybergrandchallenge/ (accessed on 4 April 2018).
  26. Shudrak, M.O.; Zolotarev, V.V. Improving fuzzing using software complexity metrics. In Proceedings of the International Conference on Information Security and Cryptology, Seoul, Korea, 25–27 November 2015; pp. 246–261. [Google Scholar]
  27. Mohamed, B.; Smaine, M. A Chi-Square-Based Decision for Real-Time Malware Detection Using PE-File Features. J. Inf. Process. Syst. 2016, 12, 644–660. [Google Scholar]
  28. Choi, J.H.; Shin, H.S.; Nasridinov, A. A Comparative Study on Data Mining Classification Techniques for Military Applications. J. Converg. 2016, 7, 1–7. [Google Scholar]
  29. Yamaguchi, F.; Lindner, F.; Rieck, K. Vulnerability extrapolation: Assisted discovery of vulnerabilities using machine learning. In Proceedings of the 5th USENIX conference on Offensive Technologies, San Francisco, CA, USA, 8 August 2011. [Google Scholar]
  30. Gustavo, G.; Guilermo, L.G.; Lucas, U.; Sanjay, R.; Josselin, F.; Laurent, M. Toward Large-Scale Vulnerability Discovery using Machine Learning. In Proceedings of the Sixth ACM conference on Data and Application Security and Privacy, New Orleans, LA, USA, 9–11 March 2016; pp. 85–96. [Google Scholar]

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.