用外部知识和自我评估提升大模型生成的漏洞检测器鲁棒性
Evaluating and Improving the Robustness of Security Attack Detectors Generated by LLMs
- 引入检索增强与自排序机制,让大模型生成更可靠的检测代码
- 对跨站脚本和SQL注入检测的F2分数提升最高达71个百分点
- 适合安全开发、AI辅助编程及漏洞检测研究者参考
大型语言模型(LLMs)正被用于生成实现安全需求的函数,如攻击检测器。然而,确保模型具备足够的攻击知识仍是挑战。为此,本文提出在LLM流程中集成检索增强生成(RAG)与自排序技术:RAG通过引入外部知识源增强输出鲁棒性,自排序则借鉴自一致性思想,生成多条推理路径并排序选择最可靠的检测器。我们在面向网页安全中两类常见注入攻击——跨站脚本(XSS)与SQL注入(SQLi)的代码生成任务上进行了广泛实证研究。结果表明,采用RAG与自排序后,XSS检测的F2-Score平均提升37%点(最高达71%点),SQLi检测平均提升6%点(最高达43%点),显著提升了生成检测器的性能。
原文摘要 · Abstract (English)
Large Language Models (LLMs) are increasingly used in software development to generate functions, such as attack detectors, that implement security requirements. A key challenge is ensuring the LLMs have enough knowledge to address specific security requirements, such as information about existing attacks. For this, we propose an approach integrating Retrieval Augmented Generation (RAG) and Self-Ranking into the LLM pipeline. RAG enhances the robustness of the output by incorporating external knowledge sources, while the Self-Ranking technique, inspired by the concept of Self-Consistency, generates multiple reasoning paths and creates ranks to select the most robust detector. Our extensive empirical study targets code generated by LLMs to detect two prevalent injection attacks in web security: Cross-Site Scripting (XSS) and SQL injection (SQLi). Results show a significant improvement in detection performance while employing RAG and Self-Ranking, with an increase of up to 71%pt (on average 37%pt) and up to 43%pt (on average 6%pt) in the F2-Score for XSS and SQLi detection, respectively.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。