arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2601.06419cs.CRcs.PL
收藏

轻量却安全:通过轻量LLM实现安全脚本语言生成

Lightweight Yet Secure: Secure Scripting Language Generation via Lightweight LLMs

Institute of Information Engineering, Chinese Academy of Sciences(中国科学院信息工程研究所);Trinity University(三一大学);Microsoft Research(微软研究院)

Keyang Zhang, Zeyu Chen, Xuan Feng, Dongliang Fang, Yaowen Zheng, Zhi Li, Limin Sun

AI总结:

本文提出PSSec框架,通过数据合成与微调提升轻量LLM在生成安全PowerShell脚本方面的能力,显著降低推理成本。

摘要:

鉴于PowerShell等脚本语言强大的自动化和管理能力,其安全性至关重要,通常以提升权限的方式使用。目前,确保这些语言的安全仍然需要大量的人力来制定和执行规则,给普通管理员带来沉重负担,并产生关键的生产风险(例如,误操作导致服务器关闭)。大型语言模型(LLMs)在代码生成、漏洞检测和自动化修复方面展示了强大的能力,尤其是在Python和JavaScript等语言中。然而,它们在帮助生成安全脚本语言代码方面的能力仍然很少被探索。在本文中,我们提出了SecGenEval-PS,一个用于系统评估LLMs在安全脚本生成、安全分析和自动化修复方面的基准。我们的结果表明,无论是专有还是开源模型,在这些领域都表现不佳。例如,GPT-4o和o3-mini生成的超过60%的PowerShell脚本在没有结构化指导的情况下是不安全的。为了弥补这一差距,我们提出PSSec,一个结合数据合成与微调的框架,以增强模型的安全能力。我们开发了一个自我调试代理,它集成了静态分析器和高级LLM的推理能力,以合成大规模的不安全脚本、违规分析及相应的修复。然后,我们使用监督微调(SFT)和强化学习(RL)对轻量级LLM(参数量低至1.7B)进行微调,使模型具备安全推理能力和生成安全PowerShell代码的能力。在多个LLM家族中,包括GPT和Qwen,PSSec训练的模型在PowerShell安全任务上表现匹配或超越通用大型模型,同时将推理成本降低了一个数量级。

英文摘要:

The security of scripting languages such as PowerShell is critical given their powerful automation and administration capabilities, often exercised with elevated privileges. Today, securing these languages still demands substantial human effort to craft and enforce rules, imposing heavy burdens on typical administrators and creating critical production risks (e.g., misoperations that shut down servers).Large language models (LLMs) have demonstrated strong capabilities in code generation, vulnerability detection, and automated repair for languages like Python and JavaScript. However, their ability to assist with generating secure scripting-language code remains largely underexplored. In this paper, we present SecGenEval-PS, a benchmark designed to systematically evaluate LLMs on secure scripting generation, security analysis, and automated repair. Our results show that both proprietary and open-source models fall short in these areas. For instance, over 60% of PowerShell scripts produced by GPT-4o and o3-mini are insecure without structured guidance.To bridge this gap, we propose PSSec, a framework that combines data synthesis with fine-tuning to enhance model security capabilities. We develop a self-debugging agent that integrates static analyzers with the reasoning abilities of advanced LLMs to synthesize large-scale structured triplets of insecure scripts, violation analyses, and corresponding repairs. We then fine-tune lightweight LLMs (as small as 1.7B parameters) using supervised fine-tuning (SFT) and reinforcement learning (RL), enabling security-aware reasoning and the generation of secure PowerShell code.Across multiple LLM families, including GPT and Qwen, \textit{PSSec}-trained models match or surpass general-purpose large models on PowerShell security tasks while reducing inference cost by more than an order of magnitude.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑