A Static Detection Method for SQL Injection Vulnerability Based on Program Transformation
<p>An example of an SQL injection attack against a web application that applies OODBE.</p> "> Figure 2
<p>The overall architecture of ODBE-SCAN.</p> "> Figure 3
<p>Comparison chart of real vulnerabilities detected by three tools in the dataset.</p> "> Figure 4
<p>Comparison chart of false positive detected by three tools in the dataset.</p> ">
Abstract
:1. Introduction
2. Background
2.1. SQL Injection Vulnerability
2.2. Database Extensions
2.3. Taint Analysis
3. Motivating Example
- Existing static analysis techniques do not model object-oriented data types, which leads to the inability to find sink points in web applications that utilize OODBE. As a result, static analysis cannot proceed properly, leading to a significant number of false negatives;
- A few static analysis techniques have modeled object-oriented data types, but they use regular expression matching to find sink functions. They only match the object and the called method (e.g., ) without determining which class instantiated the object, causing contamination propagation and resulting in numerous false positives.
4. Design
4.1. DBE-Converter
4.1.1. Key Statement Identification
Algorithm 1: key statement identification |
4.1.2. Call Relation Verification
Algorithm 2: data flow analysis |
4.1.3. Program Transformation
4.2. Vulnerability Scanner
4.2.1. Build Control Flow Graph
4.2.2. Taint Analysis
- Perform backward data flow analysis on the parameters of the sink point. Specifically, we traverse all the base blocks to find those whose summaries match the parameters and have not been sanitized. We collect all the information related to the parameters in the block summary and continue the backward trace through the entry links of the blocks. During the data flow analysis, we collect the results of the processing of the parameters in each base block and summarize them, including their sanitization status;
- Context-sensitive data flow analysis is performed at the source point. When a parameter arrives at a source point through the data flow analysis, we perform a context-sensitive data flow analysis on it. This is mainly to achieve two goals: to identify the vulnerability type and to check if the sanitization function has processed the parameter. Depending on the vulnerability type, a different analyzer is invoked to identify the context in the tag. Based on the context, specific vulnerability flags are identified.
5. Evaluation
5.1. Setup
5.2. Comparison with RIPS
5.3. Comparison with Seay
- Path-insensitive data flow analysis;
- Sanitization through database whitelist
- Wrong content-type
6. Discussion
6.1. Cost-Effectiveness and Scalability
6.2. Limitation
6.3. Future Work
6.4. Related Work
7. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- CNVD. Available online: https://www.cnvd.org.cn/ (accessed on 12 September 2023).
- Hu, J.W.; Zhao, W.; Yan, Y.; Zhang, R. Analysis and Implementation of SQL Injection Vulnerability Mining Technology Based on Machine Learning. Inf. Netw. Secur. 2019, 19, 36–42. [Google Scholar]
- Dahse, J.; Holz, T. Simulation of Built-in PHP Features for Precise Static Code Analysis. In Proceedings of the NDSS, San Diego, CA, USA, 23 February 2014. [Google Scholar]
- Jovanovic, N.; Kruegel, C.; Kirda, E. Pixy: A static analysis tool for detecting web application vulnerabilities. In Proceedings of the 2006 IEEE Symposium on Security and Privacy (S&P’06), Oakland, CA, USA, 21–24 May 2006. [Google Scholar]
- Nunes, P.J.C.; Fonseca, J.; Vieira, M. phpSAFE: A security analysis tool for OOP web application plugins. In Proceedings of the 2015 45th Annual IEEE/IFIP International Conference on Dependable Systems and Networks, Ashington, DC, USA, 22–25 June 2015. [Google Scholar]
- Nashaat, M.; Ali, K.; Miller, J. Detecting Security Vulnerabilities in Object-Oriented PHP Programs. In Proceedings of the 2017 IEEE 17th International Working Conference on Source Code Analysis and Manipulation (SCAM), Shanghai, China, 17–18 September 2017. [Google Scholar]
- Jahanshahi, R.; Doupé, A.; Egele, M. You shall not pass: Mitigating sql injection attacks on legacy web applications. In Proceedings of the 15th ACM Asia Conference on Computer and Communications Security, Taipei, Taiwan, 5–9 October 2020. [Google Scholar]
- Luo, C.; Li, P.; Meng, W. TChecker: Precise Static Inter-Procedural Analysis for Detecting Taint-Style Vulnerabilities in PHP Applications. In Proceedings of the Proceedings of the 2022 ACM SIGSAC Conference on Computer and Communications Security, Los Angeles, CA, USA, 7–11 November 2022. [Google Scholar]
- Yan, X.X.; Ma, H.T. A New Static Vulnerabilities Analysis Algorithm for PHP Codes. In Proceedings of the 2017 International Conference on Network and Information Systems for Computers (ICNISC), Shanghai, China, 14–16 April 2017. [Google Scholar]
- Son, S.; Shmatikov, V. SAFERPHP: Finding semantic vulnerabilities in PHP applications. In Proceedings of the ACM SIGPLAN 6th Workshop on Programming Languages and Analysis for Security, San Jose, CA, USA, 5 June 2011. [Google Scholar]
- Dahse, J. Static Detection of Complex Vulnerabilities in Modern PHP Applications. Ph.D. Thesis, Ruhr-Universität Bochum, Bochum, Germany, 2016. [Google Scholar]
- Alhuzali, A.; Gjomemo, R.; Eshete, B.; Venkatakrishnan, V. {NAVEX}: Precise and scalable exploit generation for dynamic web applications. In Proceedings of the 27th USENIX Security Symposium (USENIX Security 18), Baltimore, MD, USA, 15–17 August 2018. [Google Scholar]
- Dahse, J.; Krein, N.; Holz, T. Code reuse attacks in php: Automated pop chain generation. In Proceedings of the 2014 ACM SIGSAC Conference on Computer and Communications Security, Scottsdale, AZ, USA, 3–7 November 2014. [Google Scholar]
- Backes, M.; Rieck, K.; Skoruppa, M.; Stock, B.; Yamaguchi, F. Efficient and flexible discovery of php application vulnerabilities. In Proceedings of the 2017 IEEE european symposium on security and privacy (EuroS&P), Paris, France, 26–28 April 2017. [Google Scholar]
- Cnseay. Available online: https://github.com/f1tz/cnseay/ (accessed on 10 September 2023).
- Li, P.; Meng, W. Lchecker: Detecting loose comparison bugs in php. In Proceedings of the Web Conference 2021, Virtual, 19–23 April 2021. [Google Scholar]
- Clarke, J. SQL Injection Attacks and Defense, 2nd ed.; Tsinghua University Press: Beijing, China, 2014; pp. 1+5. [Google Scholar]
- Denning, D.E. A lattice model of secure information flow. Commun. ACM 1976, 19, 236–243. [Google Scholar] [CrossRef]
- Denning, D.E.; Denning, P.J. Certification of programs for secure information flow. Commun. ACM 1977, 20, 504–513. [Google Scholar] [CrossRef]
- Shankar, U.; Talwar, K.; Foster, J.S.; Wagner, D. Detecting format string vulnerabilities with type qualifiers. In Proceedings of the 10th USENIX Security Symposium (USENIX Security 01), Washington, DC, USA, 13–17 August 2001. [Google Scholar]
- Foster, J.S.; Terauchi, T.; Aiken, A. Flow-sensitive type qualifiers. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, Berlin, Germany, 17–19 June 2002. [Google Scholar]
- Lam, M.S.; Martin, M.; Livshits, B.; Whaley, J. Securing web applications with static and dynamic information flow tracking. In Proceedings of the 2008 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation, San Francisco, CA, USA, 7–8 January 2008. [Google Scholar]
- Taint Analysis. Available online: https://wiki.sei.cmu.edu/confluence/display/c/Taint+Analysis (accessed on 10 September 2023).
- Xu, W.; Bhatkar, S.; Sekar, R. Taint-enhanced policy enforcement: A practical approach to defeat a wide range of attacks. In Proceedings of the USENIX Security Symposium, Vancouver, BC, Canada, 31 July–4 August 2006. [Google Scholar]
- Aho, A.V. Compilers: Principles, Techniques and Tools (for Anna University), 2/e; Pearson Education: New Delhi, India, 2003. [Google Scholar]
- Davis, B.; Chen, H. {DBTaint}:{Cross-Application} information flow tracking via databases. In Proceedings of the USENIX Conference on Web Application Development (WebApps 10), Boston, MA, USA, 23–24 June 2010. [Google Scholar]
- Bravenboer, M.; Smaragdakis, Y. Strictly declarative specification of sophisticated points-to analyses. In Proceedings of the 24th ACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, Orlando, FL, USA, 25–29 October 2009. [Google Scholar]
- Enck, W.; Gilbert, P.; Han, S.; Tendulkar, V.; Chun, B.G.; Cox, L.P.; Jung, J.; McDaniel, P.; Sheth, A.N. Taintdroid: An information-flow tracking system for realtime privacy monitoring on smartphones. ACM Trans. Comput. Syst. TOCS 2014, 32, 1–29. [Google Scholar] [CrossRef]
- Medeiros, I.; Neves, N.; Correia, M. Detecting and removing web application vulnerabilities with static analysis and data mining. IEEE Trans. Reliab. 2015, 65, 54–69. [Google Scholar] [CrossRef]
- Zhao, J.; Lu, Y.; Zhu, K.; Chen, Z.; Huang, H. Cefuzz: An directed fuzzing framework for php rce vulnerability. Electronics 2022, 11, 758. [Google Scholar] [CrossRef]
- Wang, M.; Jung, C.; Ahad, A.; Kwon, Y. Spinner: Automated Dynamic Command Subsystem Perturbation. In Proceedings of the 2021 ACM SIGSAC Conference on Computer and Communications Security, Virtual Event Republic of Korea, 15–19 November 2021. [Google Scholar]
- Shi, C.c.; Zhang, T.; Yu, Y.; Lin, W. A new approach for SQL-injection detection. In Proceedings of the Instrumentation, Measurement, Circuits and Systems, Hong Kong, China, 12–13 December 2012. [Google Scholar]
- Zhang, K. A machine learning based approach to identify SQL injection vulnerabilities. In Proceedings of the 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), San Diego, CA, USA, 11–15 November 2019. [Google Scholar]
- Boyd, S.W.; Keromytis, A.D. SQLrand: Preventing SQL injection attacks. In Proceedings of the Applied Cryptography and Network Security: Second International Conference, ACNS 2004, Yellow Mountain, China, 8–11 June 2004. [Google Scholar]
- Huang, Y.W.; Huang, S.K.; Lin, T.P.; Tsai, C.H. Web application security assessment by fault injection and behavior monitoring. In Proceedings of the 12th International Conference on World Wide Web, Budapest, Hungary, 20–24 May 2003. [Google Scholar]
- Trickel, E.; Pagani, F.; Zhu, C.; Dresel, L.; Vigna, G.; Kruegel, C.; Wang, R.; Bao, T.; Shoshitaishvili, Y.; Doupé, A. Toss a fault to your witcher: Applying grey-box coverage-guided mutational fuzzing to detect sql and command injection vulnerabilities. In Proceedings of the 2023 IEEE Symposium on Security and Privacy (SP), San Francisco, CA, USA, 21–25 May 2023. [Google Scholar]
- van Rooij, O.; Charalambous, M.A.; Kaizer, D.; Papaevripides, M.; Athanasopoulos, E. webfuzz: Grey-box fuzzing for web applications. In Proceedings of the Computer Security–ESORICS 2021: 26th European Symposium on Research in Computer Security, Darmstadt, Germany, 4–8 October 2021. [Google Scholar]
- Wang, J.; Phan, R.C.W.; Whitley, J.N.; Parish, D.J. Augmented attack tree modeling of SQL injection attacks. In Proceedings of the 2010 2nd IEEE International Conference on Information Management and Engineering, Chengdu, China, 16–18 April 2010. [Google Scholar]
- Wei, T. Model-Driven Penetration Test of the SQL Injection in Web Applications. Ph.D. Thesis, Nankai University, Tianjin, China, 2012. [Google Scholar]
- Chen, X.-L. The Research and Realization of SQL Vulnerability Detection System for Web Application. Master’s Thesis, Southwest Jiaotong University, Chengdu, China, 2013. [Google Scholar]
Application | Size | Version | Release Date | Language (S) | Lines of Code | Numbers (Files) | Numbers (Vulnerabilities) | Known Vulnerabilities |
---|---|---|---|---|---|---|---|---|
Best POS Management System | 40 MB | 1.0 | 2023.02 | PHP/XML | 155259 | 2057 | 6 | CVE-2023-3617CVE-2023-27205 CVE-2023-27204CVE-2023-27203 CVE-2023-27202CVE-2023-0946 |
Online Food Ordering System | 37.8 MB | 2.0 | 2023.01 | PHP/XML | 131173 | 1810 | 6 | CVE-2023-24197CVE-2023-0332 CVE-2023-0305CVE-2023-0304 CVE-2023-0303CVE-2023-0256 |
Raffle Draw system | 149 KB | 1.0 | 2022.12 | PHP | 770 | 18 | 4 | CVE-2023-24201CVE-2023-24200 CVE-2023-24199CVE-2023-24198 |
Pizza Ordering System | 24 MB | 1.0 | 2023.02 | PHP/XML | 131413 | 1812 | 8 | CVE-2023-30092CVE-2023-27210 CVE-2023-27207CVE-2023-1455 CVE-2023-1365CVE-2023-1364 CVE-2023-0910CVE-2023-0883 |
Online Traffic Offense Management System | 67.3 MB | 1.0 | 2023.02 | PHP/JS/XML | 546033 | 1967 | 3 | CVE-2023-2075CVE-2023-2074 CVE-2023-2073 |
Vehicle Service Management System | 64.6 MB | 1.0 | 2021.09 | PHP/JS/XML | 545768 | 1976 | 8 | CVE-2023-2097CVE-2023-2096 CVE-2023-2095CVE-2023-2094 CVE-2023-2093CVE-2023-2092 CVE-2023-0913CVE-2023-37806 |
Eduauth | 24.7 MB | 1.0 | 2023.02 | PHP/XML | 139159 | 1248 | 3 | CVE-2023-27214CVE-2023-27213 CVE-2023-1099 |
Judging Management System | 4.17 MB | 1.0 | 2022.12 | PHP | 48570 | 109 | 12 | CVE-2023-24643CVE-2023-24642 CVE-2023-24641CVE-2023-2108 CVE-2023-1556CVE-2023-46623 CVE-2023-30018CVE-2023-30076 CVE-2023-30077CVE-2023-30203 CVE-2023-30204CVE-2023-37682 |
OODBE-SCAN | RIPS | Seay | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
application | TP | FP | P | R | TP | FP | P | R | TP | FP | P | R |
Best POS Management System | 5 | 7 | 0.42 | 0.83 | 0 | 33 | 0 | 0 | 1 | 23 | 0.04 | 0.17 |
Online Food Ordering System | 5 | 8 | 0.38 | 0.83 | 1 | 26 | 0.04 | 0.17 | 2 | 20 | 0.09 | 0.33 |
Raffle Draw system | 4 | 2 | 0.67 | 1 | 0 | 0 | 0 | 0 | 3 | 1 | 0.75 | 0.75 |
Pizza Ordering System | 7 | 9 | 0.44 | 0.88 | 2 | 26 | 0.07 | 0.25 | 2 | 21 | 0.09 | 0.25 |
Traffic offense | 2 | 3 | 0.4 | 0.67 | 1 | 58 | 0.02 | 0.33 | 2 | 14 | 0.13 | 0.67 |
Vehicle service | 7 | 12 | 0.37 | 0.88 | 4 | 74 | 0.05 | 0.5 | 5 | 17 | 0.23 | 0.63 |
Eduauth | 3 | 2 | 0.6 | 0.67 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0.33 |
Judging Management System | 8 | 9 | 0.47 | 0.67 | 0 | 0 | 0 | 0 | 8 | 20 | 0.29 | 0.67 |
TOTAL | 41 | 52 | 0.44 | 0.82 | 8 | 217 | 0.04 | 0.16 | 24 | 116 | 0.17 | 0.48 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Yuan, Y.; Lu, Y.; Zhu, K.; Huang, H.; Yu, L.; Zhao, J. A Static Detection Method for SQL Injection Vulnerability Based on Program Transformation. Appl. Sci. 2023, 13, 11763. https://doi.org/10.3390/app132111763
Yuan Y, Lu Y, Zhu K, Huang H, Yu L, Zhao J. A Static Detection Method for SQL Injection Vulnerability Based on Program Transformation. Applied Sciences. 2023; 13(21):11763. https://doi.org/10.3390/app132111763
Chicago/Turabian StyleYuan, Ye, Yuliang Lu, Kailong Zhu, Hui Huang, Lu Yu, and Jiazhen Zhao. 2023. "A Static Detection Method for SQL Injection Vulnerability Based on Program Transformation" Applied Sciences 13, no. 21: 11763. https://doi.org/10.3390/app132111763
APA StyleYuan, Y., Lu, Y., Zhu, K., Huang, H., Yu, L., & Zhao, J. (2023). A Static Detection Method for SQL Injection Vulnerability Based on Program Transformation. Applied Sciences, 13(21), 11763. https://doi.org/10.3390/app132111763