《计算机应用》唯一官方网站 ›› 2023, Vol. 43 ›› Issue (5): 1534-1542.DOI: 10.11772/j.issn.1001-9081.2022040636
所属专题: 网络空间安全
收稿日期:
2022-05-07
修回日期:
2022-06-21
发布日期:
2022-07-26
出版日期:
2023-05-10
通讯作者:
何成万
作者简介:
刘吉会(1996—),男,湖北麻城人,硕士研究生,主要研究方向:数据安全基金资助:
Received:
2022-05-07
Revised:
2022-06-21
Online:
2022-07-26
Published:
2023-05-10
Contact:
Chengwan HE
About author:
LIU Jihui, born in 1996, M. S. candidate. His research interests include data security.Supported by:
摘要:
SQL注入攻击是一种常见的针对Web应用程序漏洞的攻击形式。任何形式的SQL注入攻击最终都会改变原有SQL语句的逻辑结构,违背设计者的初衷。现有的SQL注入攻击检测方法存在检测代码不易被重用、不能被在线注入Web应用程序等不足。因此,提出一种基于ECA(Event Condition Action)规则和动态污点分析的在线检测SQL注入攻击的模型。首先,定义污点标记规则监视污点源函数以标记系统外部引入数据;然后,定义污点传播规则实时跟踪污点数据在应用内部的流向;接着,定义污点检查规则以拦截污点汇聚点函数的参数,并解析它可能携带的污点状态;最后,在原始的Web应用运行时加载ECA规则脚本达到在线检测SQL注入攻击的目的,Web应用无须重新编译、打包和部署。使用Byteman实现了所提模型。在两个不同的Web应用测试实验中,该模型可以识别绝大多数的SQL注入攻击样本,对于正常请求样本没有误报,检测准确率可达99.42%,优于基于支持向量机(SVM)和基于词频逆向文件频率(TF-IDF)的方法;与基于面向方面编程(AOP)的方法相比,该模型易于在Web应用启动后在线加载检测模块。实验结果表明所提模型能够在不修改应用程序执行引擎及源码的情况下,检测6种常见的SQL注入攻击类型,且具有在线检测的优点。
中图分类号:
刘吉会, 何成万. 基于ECA规则和动态污点分析的SQL注入攻击在线检测[J]. 计算机应用, 2023, 43(5): 1534-1542.
Jihui LIU, Chengwan HE. Online detection of SQL injection attacks based on ECA rules and dynamic taint analysis[J]. Journal of Computer Applications, 2023, 43(5): 1534-1542.
编号 | 类型 | 测试用例 | 攻击字符信息 | 检测结果 |
---|---|---|---|---|
1 | 重言式 | SELECT * FROM user_data WHERE last_name = 'Smith' or '1'='1' | ',or,',',=,' | √ |
2 | 非法或逻辑错误查询 | SELECT * FROM user_data WHERE last_name = 'Smith'' | ' | √ |
3 | 联合查询 | SELECT * FROM user_data WHERE last_name ='' union select userid,user_name,password,null,null,cookie,null from user_system_data -- ' | ',password,null,null,null,from,select,union,-- | √ |
4 | 堆叠查询 | SELECT * FROM user_data WHERE last_name = ''; select * from user_system_data -- ' | ',from,select,;,-- | √ |
5 | 构造函数 | select * from users where pwd=system_user() | system_user,(,) | √ |
6 | 推理查询 | select * from users where name='Smith' and '1'='1' select * from users where name='Smith' and '1'='2' | ',and,',',=,' | √ |
表1 SQL注入测试用例及检测结果
Tab. 1 SQL injection test cases and detection results
编号 | 类型 | 测试用例 | 攻击字符信息 | 检测结果 |
---|---|---|---|---|
1 | 重言式 | SELECT * FROM user_data WHERE last_name = 'Smith' or '1'='1' | ',or,',',=,' | √ |
2 | 非法或逻辑错误查询 | SELECT * FROM user_data WHERE last_name = 'Smith'' | ' | √ |
3 | 联合查询 | SELECT * FROM user_data WHERE last_name ='' union select userid,user_name,password,null,null,cookie,null from user_system_data -- ' | ',password,null,null,null,from,select,union,-- | √ |
4 | 堆叠查询 | SELECT * FROM user_data WHERE last_name = ''; select * from user_system_data -- ' | ',from,select,;,-- | √ |
5 | 构造函数 | select * from users where pwd=system_user() | system_user,(,) | √ |
6 | 推理查询 | select * from users where name='Smith' and '1'='1' select * from users where name='Smith' and '1'='2' | ',and,',',=,' | √ |
Web应用 | SQL注入攻击 的样本数 | 成功检测到 攻击的样本数 | 准确率/% |
---|---|---|---|
bookstore | 679 | 679 | 99.42 |
WebGoat | 527 | 520 |
表2 恶意请求样本检测结果
Tab. 2 Detection results of malicious request samples
Web应用 | SQL注入攻击 的样本数 | 成功检测到 攻击的样本数 | 准确率/% |
---|---|---|---|
bookstore | 679 | 679 | 99.42 |
WebGoat | 527 | 520 |
Web应用 | 正常请求的样本数 | 检测到SQL注入行为的样本数 |
---|---|---|
bookstore | 449 | 0 |
WebGoat | 396 | 0 |
表3 正常请求样本检测结果
Tab. 3 Detection results of normal request samples
Web应用 | 正常请求的样本数 | 检测到SQL注入行为的样本数 |
---|---|---|
bookstore | 449 | 0 |
WebGoat | 396 | 0 |
检测方法来源 | SQL注入类型 | |||||
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
文献[ | * | * | * | * | * | * |
文献[ | √ | × | × | × | × | × |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
本文 | √ | √ | √ | √ | √ | √ |
表4 不同方法的检测能力比较
Tab. 4 Comparison of detection capability of different methods
检测方法来源 | SQL注入类型 | |||||
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
文献[ | * | * | * | * | * | * |
文献[ | √ | × | × | × | × | × |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
文献[ | √ | √ | √ | √ | √ | √ |
本文 | √ | √ | √ | √ | √ | √ |
检测方法来源 | 额外配置 | 自动化程度 | 加载检测模块 |
---|---|---|---|
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | PHP解释器 | automated | 离线加载 |
文献[ | C++重载 | automated | 离线加载 |
文献[ | 继承和替代字符串类 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
本文 | 无 | automated | 在线加载 |
表5 不同方法的部署要求比较
Tab. 5 Comparison of deployment requirements for different methods
检测方法来源 | 额外配置 | 自动化程度 | 加载检测模块 |
---|---|---|---|
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | PHP解释器 | automated | 离线加载 |
文献[ | C++重载 | automated | 离线加载 |
文献[ | 继承和替代字符串类 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
文献[ | 无 | automated | 离线加载 |
本文 | 无 | automated | 在线加载 |
应用 | 注入点 | 请求 类型 | 平均响应时间 | |
---|---|---|---|---|
加载前 | 加载后 | |||
WebGoat | attack5a | 正常 | 18 | 29 |
恶意 | 12 | 16 | ||
attack5b | 正常 | 9 | 15 | |
恶意 | 9 | 14 | ||
bookstore | Login.jsp | 正常 | 23 | 24 |
恶意 | 17 | 30 |
表6 注入点加载前后的平均响应时间比较 ( ms)
Tab. 6 Comparison of average response time before and after loading injection points
应用 | 注入点 | 请求 类型 | 平均响应时间 | |
---|---|---|---|---|
加载前 | 加载后 | |||
WebGoat | attack5a | 正常 | 18 | 29 |
恶意 | 12 | 16 | ||
attack5b | 正常 | 9 | 15 | |
恶意 | 9 | 14 | ||
bookstore | Login.jsp | 正常 | 23 | 24 |
恶意 | 17 | 30 |
1 | GUPTA H, MONDAL S, RAY S, et al. Impact of SQL injection in database security[C]// Proceedings of the 2019 International Conference on Computational Intelligence and Knowledge Economy. Piscataway: IEEE, 2019: 296- 299. 10.1109/iccike47802.2019.9004430 |
2 | LEKSHMI A S SAI, DEVIPRIYA V S. An emulation of SQL injection disclosure and deterrence[C]// Proceedings of the 2017 International Conference on Networks and Advances in Computational Technologies. Piscataway: IEEE, 2017: 314- 316. 10.1109/netact.2017.8076787 |
3 | 王小群, 丁丽, 严寒冰, 等. 2020年我国互联网网络安全态势综述[J]. 保密科学技术, 2021( 5): 3- 10. |
WANG X Q, DING L, YAN H B, et al. Review of Internet network security situation of China in 2020[J]. Secrecy Science and Technology, 2021( 5): 3- 10. | |
4 | Open Web Application Security Project. OWASP TOP 10 — 2017: the ten most critical Web application security risks[EB/OL]. [ 2022-04-25]. . |
5 | RAY D, LIGATTI J. Defining code-injection attacks[J]. ACM SIGPLAN Notices, 2012, 47( 1): 179- 190. 10.1145/2103621.2103678 |
6 | RAY D, LIGATTI J. Defining injection attacks[C]// Proceedings of the 2014 International Conference on Information Security, LNCS 8783. Cham: Springer, 2014: 425- 441. |
7 | 张慧琳, 丁羽, 张利华, 等. 基于敏感字符的SQL注入攻击防御方法[J]. 计算机研究与发展, 2016, 53( 10): 2262- 2276. 10.7544/issn1000-1239.2016.20160443 |
ZHANG H L, DING Y, ZHANG L H, et al. SQL injection attack defense method based on sensitive characters[J]. Journal of Computer Research and Development, 2016, 53( 10): 2262- 2276. 10.7544/issn1000-1239.2016.20160443 | |
8 | 白鑫玉. SQL注入攻击检测技术研究[D]. 北京: 北京交通大学, 2021: 1- 5. |
BAI X Y. Research on the SQL injection attack detection technology[D]. Beijing: Beijing Jiaotong University, 2021: 1- 5. | |
9 | GOULD C, SU Z D, DEVANBU P. JDBC checker: a static analysis tool for SQL/JDBC applications[C]// Proceedings of the 26th International Conference on Software Engineering. Piscataway: IEEE, 2004: 697- 698. |
10 | BANDHAKAVI S, BISHT P, MADHUSUDAN P, et al. CANDID: preventing SQL injection attacks using dynamic candidate evaluations[C]// Proceedings of the 14th ACM Conference on Computer and Communications Security. New York: ACM, 2007: 12- 24. 10.1145/1315245.1315249 |
11 | HALFOND W G J, ORSO A. AMNESIA: analysis and monitoring for neutralizing SQL-injection attacks[C]// Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering. New York: ACM, 2005: 174- 183. 10.1145/1101908.1101935 |
12 | DINN A. Byteman programmer's guide 4. 0. 13 [EB/OL]. [ 2021-10-10]. . 10.1145/1960314.1960325 |
13 | Open Web Application Security Project. WebGoat[EB/OL]. [ 2021-11-21]. . |
14 | HALFOND W G J, VIEGAS J, ORSO A. A classification of SQL injection attacks and countermeasures[C/OL]// Proceedings of the 2006 International Conference on Secure Software Engineering [2022-03-21]. . |
15 | SOEWITO B, GUNAWAN F E, HIRZI, et al. Prevention structured query language injection using regular expression and escape string[J]. Procedia Computer Science, 2018, 135: 678- 687. 10.1016/j.procs.2018.08.218 |
16 | 何成万, 青旺, 徐雅琴, 等. 基于AOP与SQL结构分析的SQLIAs动态检测及防御[J]. 计算机工程, 2018, 44( 4): 154- 160. 10.3969/j.issn.1000-3428.2018.04.025 |
HE C W, QING W, XU Y Q, et al. Dynamic detection and defense of SQLIAs based on AOP and SQL structure analysis[J]. Computer Engineering, 2018, 44( 4): 154- 160. 10.3969/j.issn.1000-3428.2018.04.025 | |
17 | MANOJ R J, CHANDRASEKHAR A, PRAVEENA M D A. An approach to detect and prevent tautology type SQL injection in Web service based on XSchema validation[J]. International Journal of Engineering and Computer Science, 2014, 10: 2319- 7242. |
18 | JOVANOVIC N, KRUEGEL C, KIRDA E. Pixy: a static analysis tool for detecting Web application vulnerabilities[C]// Proceedings of the 2006 IEEE Conference on Security and Privacy. Piscataway: IEEE, 2006: 258- 263. 10.1109/sp.2006.29 |
19 | LIVSHITS V B, LAM M S. Finding security vulnerabilities in java applications with static analysis[C]// Proceedings of the 14th USENIX Security Symposium. Berkeley: USENIX Association, 2005: 271- 286. 10.1109/msp.2004.9 |
20 | WASSERMANN G, SU Z D. Sound and precise analysis of Web applications for injection vulnerabilities[C]// Proceedings of the 28th ACM SIGPLAN Conference on Programming Language Design and Implementation. New York: ACM, 2007: 32- 41. 10.1145/1250734.1250739 |
21 | HALDAR V, CHANDRA D, FRANZ M. Dynamic taint propagation for Java[C]// Proceedings of the 21st Annual Computer Security Applications Conference. Piscataway: IEEE, 2006: 303- 311. |
22 | WALL L, CHRISTIANSEN T, ORWANT J. Programming Perl[M]. 3rd ed. Sebastopol, CA: O’Reilly Media, Inc., 2000: 503- 503. |
23 | NGUYEN-TUONG A, GUARNIERI S, GREENE D, et al. Automatically hardening Web applications using precise tainting[C]// Proceedings of 2005 IFIP International Information Security Conference, IFIPAICT 181. Boston: Springer, 2005: 295- 307. 10.1007/0-387-25660-1_20 |
24 | RAFAILIDIS F, PANAGOS I, KATSAROS P, et al. Inlined monitors for security policy enforcement in Web applications[C]// Proceedings of the 17th Panhellenic Conference on Informatics. New York: ACM, 2013: 75- 82. 10.1145/2491845.2491861 |
25 | CHIN E, WAGNER D. Efficient character-level taint tracking for Java[C]// Proceedings of the 2009 ACM Workshop on Secure Web Services. New York: ACM, 2009: 3- 12. 10.1145/1655121.1655125 |
26 | 董敏. 基于动态污点分析的SQL注入攻击检测问题的研究[D]. 北京: 北京工业大学, 2014: 23- 39. |
DONG M. Research on the attack detection of SQL injection based on dynamic analysis[D]. Beijing: Beijing University of Technology, 2014: 23- 39. | |
27 | HALFOND W, ORSO A, MANOLIOS P. WASP: protecting Web applications using positive tainting and syntax-aware evaluation[J]. IEEE Transactions on Software Engineering, 2008, 34( 1): 65- 81. 10.1109/tse.2007.70748 |
28 | 何成万, 叶志鹏. 基于AOP和动态污点分析的SQL注入行为检测方法[J]. 电子学报, 2019, 47( 11): 2413- 2419. 10.3969/j.issn.0372-2112.2019.11.025 |
HE C W, YE Z P. SQL injection behavior detection method based on AOP and dynamic taint analysis[J]. Acta Electronica Sinica, 2019, 47( 11): 2413- 2419. 10.3969/j.issn.0372-2112.2019.11.025 | |
29 | HE C W, HE Y. A reusable SQL injection detection method for Java Web applications[J]. KSII Transactions on Internet and Information Systems, 2020, 14( 6): 2576- 2590. 10.3837/tiis.2020.06.014 |
30 | 李红灵, 邹建鑫. 基于SVM和文本特征向量提取的SQL注入检测研究[J]. 信息网络安全, 2017( 12): 40- 46. 10.3969/j.issn.1671-1122.2017.12.008 |
LI H L, ZOU J X. Research of SQL injection detection based on SVM and text feature extraction[J]. Netinfo Security, 2017( 12): 40- 46. 10.3969/j.issn.1671-1122.2017.12.008 | |
31 | 苏林萍, 刘小倩, 陈飞, 等. 基于N-Gram和TFIDF的SQL注入检测方法[J]. 计算机与数字工程, 2021, 49( 6): 1177- 1181. 10.3969/j.issn.1672-9722.2021.06.027 |
SU L P, LIU X Q, CHEN F, et al. SQL injection detection method based on N-Gram and TFIDF[J]. Computer and Digital Engineering, 2021, 49( 6): 1177- 1181. 10.3969/j.issn.1672-9722.2021.06.027 | |
32 | 任玉柱, 张有为, 艾成炜. 污点分析技术研究综述[J]. 计算机应用, 2019, 39( 8): 2302- 2309. 10.11772/j.issn.1001-9081.2019020238 |
REN Y Z, ZHANG Y W, AI C W. Survey on taint analysis technology[J]. Journal of Computer Applications, 2019, 39( 8): 2302- 2309. 10.11772/j.issn.1001-9081.2019020238 | |
33 | 王蕾, 李丰, 李炼, 等. 污点分析技术的原理和实践应用[J]. 软件学报, 2017, 28( 4): 860- 882. |
WANG L, LI F, LI L, et al. Principle and practice of taint analysis[J]. Journal of Software, 2017, 28( 4): 860- 882. |
[1] | 孙天齐, 胡建鹏, 黄娟, 樊莹. 云环境下Web应用带宽资源预测与管理[J]. 计算机应用, 2020, 40(1): 181-187. |
[2] | 王曙燕, 郑佳妮, 孙家泽. 基于页面对象的Web应用测试用例生成方法[J]. 计算机应用, 2020, 40(1): 212-217. |
[3] | 任玉柱, 张有为, 艾成炜. 污点分析技术研究综述[J]. 计算机应用, 2019, 39(8): 2302-2309. |
[4] | 李洁, 俞研, 吴家顺. 基于动态污点分析的DOM XSS漏洞检测算法[J]. 计算机应用, 2016, 36(5): 1246-1249. |
[5] | 曾祥飞, 郭帆, 涂风涛. 基于对象跟踪的J2EE程序动态污点分析方法[J]. 计算机应用, 2015, 35(8): 2386-2391. |
[6] | 刘晓强, 解筱梦, 杜明, 常姗, 蔡立志, 刘振宇. 面向云测试的并行测试用例自动生成方法[J]. 计算机应用, 2015, 35(4): 1159-1163. |
[7] | 房鼎益, 党舒凡, 王怀军, 董浩, 张凡. 具有时间多样性的JavaScript代码保护方法[J]. 计算机应用, 2015, 35(1): 72-76. |
[8] | 秦志光 宋旭 耿技 陈伟. 基于马尔可夫的Web应用生存性模型[J]. 计算机应用, 2013, 33(02): 400-403. |
[9] | 翁雷雷 蔡皖东 姚烨. Web应用系统负载测试加压策略研究[J]. 计算机应用, 2012, 32(10): 2973-2976. |
[10] | 吴逸伦 张博锋 赖志权 苏金树. 基于消息语义解析的软件网络行为分析[J]. 计算机应用, 2012, 32(01): 25-29. |
[11] | 林辉 吴黎明 潘启军. 弹性体工件在线检测系统中视频预处理IP核设计[J]. 计算机应用, 2011, 31(10): 2609-2611. |
[12] | 惠斌武 陈明锐 杨登攀. Web应用系统性能测试研究与应用[J]. 计算机应用, 2011, 31(07): 1769-1772. |
[13] | 何可 李晓红 冯志勇. 活动图模型驱动的Web应用程序测试方法[J]. 计算机应用, 2010, 30(9): 2365-2369. |
[14] | 施寅生 王峰 齐璇 宗建建. 基于TTCN-3的Web应用功能测试方法[J]. 计算机应用, 2010, 30(8): 2185-2188. |
[15] | 汤迪斌 王劲林 倪宏. 一种CDN中的动态数据存储方案——UbDP[J]. 计算机应用, 2008, 28(8): 1991-1993. |
阅读次数 | ||||||
全文 |
|
|||||
摘要 |
|
|||||