arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.11151cs.CLcs.CR
收藏

TypePilot:利用 Scala 类型系统保障 LLM 生成代码的安全性

TypePilot: Leveraging the Scala Type System for Secure LLM-generated Code

Institute of Entrepreneurship & Management, HES-SO Le Foyer, Techno-Pôle 1 Sierre, Switzerland(创业与管理学院,HES-SO莱福院,技术园区1,瑞士);Institute of Informatics, HES-SO Techno-Pôle 3 Sierre, Switzerland(信息学院,HES-SO技术园区3,瑞士);Cyber-Defence Campus armasuisse, Science and Technology Thun, Switzerland(网络安全校区,armasuisse,科技,瑞士)

Alexander Sternfeld, Andrei Kucharavy, Ljiljana Dolamic

AI总结:

本文提出 TypePilot 框架,利用 Scala 等强类型语言提升 LLM 生成代码的安全性,实验证明其类型导向智能体流水线能大幅缓解输入验证和注入漏洞,提升高保障领域代码生成可信度。

摘要:

大型语言模型(LLMs)在各种编程语言的代码生成任务中展现出卓越的能力。然而,其输出常包含微妙但致命的漏洞,在部署于安全敏感或关键任务系统时构成重大风险。本文提出 TypePilot,一个智能体 AI 框架,旨在通过利用强类型和可验证语言(以 Scala 为代表)来增强 LLM 生成代码的安全性与鲁棒性。我们在两种设置下评估该方法的有效性:使用 Stainless 框架进行形式化验证,以及通用安全代码生成。对领先开源 LLMs 的实验表明,与直接生成代码或简单提示生成更安全代码一样,前者往往无法强制执行安全约束;而我们的类型导向智能体流水线大幅缓解了输入验证和注入漏洞。结果表明,结构化、类型引导的 LLM 工作流具有提升高保障领域自动化代码生成可信度 SotA 的潜力。

英文摘要:

Large language Models (LLMs) have shown remarkable proficiency in code generation tasks across various programming languages. However, their outputs often contain subtle but critical vulnerabilities, posing significant risks when deployed in security-sensitive or mission-critical systems. This paper introduces TypePilot, an agentic AI framework designed to enhance the security and robustness of LLM-generated code by leveraging strongly typed and verifiable languages, using Scala as a representative example. We evaluate the effectiveness of our approach in two settings: formal verification with the Stainless framework and general-purpose secure code generation. Our experiments with leading open-source LLMs reveal that while direct code generation often fails to enforce safety constraints, just as naive prompting for more secure code, our type-focused agentic pipeline substantially mitigates input validation and injection vulnerabilities. The results demonstrate the potential of structured, type-guided LLM workflows to improve the SotA of the trustworthiness of automated code generation in high-assurance domains.

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

↑