WebShell attacks - where adversaries implant malicious scripts on web servers - remain a persistent threat. Prior machine-learning and deep-learning detectors typically depend on task-specific supervision and can be brittle under data scarcity, rapid concept drift, and out-of-distribution (OOD) deployment. Large language models (LLMs) have recently shown strong code understanding capabilities, but their reliability for WebShell detection remains unclear. We address this gap by (i) systematically evaluating seven LLMs (including GPT-4, LLaMA-3.1-70B, and Qwen-2.5 variants) against representative sequence- and graph-based baselines on 26.59K PHP scripts, and (ii) proposing Behavioral Function-Aware Detection (BFAD), a behavior-centric framework that adapts LLM inference to WebShell-specific execution patterns. BFAD anchors analysis on security-sensitive PHP functions via a Critical Function Filter, constructs compact LLM inputs with Context-Aware Code Extraction, and selects in-context demonstrations using Weighted Behavioral Function Profiling, which ranks examples by a behavior-weighted, function-level similarity. Empirically, we observe a consistent precision-recall asymmetry: larger LLMs often achieve high precision but miss attacks (lower recall), while smaller models exhibit the opposite tendency; moreover, off-the-shelf LLM prompting underperforms established detectors. BFAD substantially improves all evaluated LLMs, boosting F1 by 13.82% on average; notably, GPT-4, LLaMA-3.1-70B, and Qwen-2.5-Coder-14B exceed prior SOTA benchmarks, while Qwen-2.5-Coder-3B becomes competitive with traditional methods. Overall, our results clarify when LLMs succeed or fail on WebShell detection, provide a practical recipe, and highlight future directions for making LLM-based detection more reliable.


翻译:WebShell攻击——攻击者在Web服务器中植入恶意脚本——仍然是一种持续存在的威胁。现有的机器学习和深度学习检测器通常依赖于特定任务的监督,在数据稀缺、概念快速漂移和分布外(OOD)部署场景下表现脆弱。大型语言模型(LLMs)近期展现出强大的代码理解能力,但其用于WebShell检测的可靠性尚不明确。为填补这一空白,我们(i)系统性地评估了七种LLMs(包括GPT-4、LLaMA-3.1-70B和Qwen-2.5系列变体),在26.59K个PHP脚本上对比了基于序列和图表示的基线方法;(ii)提出了行为函数感知检测(BFAD),这是一个以行为为中心的框架,旨在使LLM推理适应WebShell特有的执行模式。BFAD通过关键函数过滤器将分析锚定在安全敏感的PHP函数上,利用上下文感知代码提取构建紧凑的LLM输入,并采用加权行为函数分析选择上下文示例,该方法通过行为加权的函数级相似度对示例进行排序。实证研究表明,我们观察到一种一致的精确率-召回率不对称现象:较大的LLMs通常能实现高精确率但会漏报攻击(召回率较低),而较小的模型则表现出相反的趋势;此外,现成的LLM提示方法表现不及已有的检测器。BFAD显著提升了所有被评估的LLMs,平均F1分数提高了13.82%;值得注意的是,GPT-4、LLaMA-3.1-70B和Qwen-2.5-Coder-14B超越了先前的最先进基准,而Qwen-2.5-Coder-3B则与传统方法具有可比性。总体而言,我们的结果阐明了LLMs在WebShell检测任务上的成功与失败条件,提供了一种实用的解决方案,并指出了未来使基于LLM的检测更加可靠的研究方向。

0
下载
关闭预览

相关内容

探索大型语言模型在网络安全中的作用:一项系统综述
专知会员服务
20+阅读 · 2025年4月27日
大型语言模型网络安全综述
专知会员服务
67+阅读 · 2024年5月12日
大型语言模型在预测和异常检测中的应用综述
专知会员服务
70+阅读 · 2024年2月19日
通信网络中大型语言模型的后门攻击的综述
专知会员服务
30+阅读 · 2023年9月5日
对抗机器学习在网络入侵检测领域的应用
专知会员服务
35+阅读 · 2022年1月4日
Xsser 一款自动检测XSS漏洞工具
黑白之道
14+阅读 · 2019年8月26日
异常检测论文大列表:方法、应用、综述
专知
126+阅读 · 2019年7月15日
SemanticAdv:基于语义属性的对抗样本生成方法
机器之心
14+阅读 · 2019年7月12日
你的算法可靠吗? 神经网络不确定性度量
专知
40+阅读 · 2019年4月27日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Arxiv
0+阅读 · 1月27日
VIP会员
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
19+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员