arXiv:2601.05467cs.SEcs.AI2026-01

为大模型生成代码设计安全执行框架,防止漏洞和恶意行为。

STELP: Secure Transpilation and Execution of LLM-Generated Programs

  • 构建可控制的代码转译执行系统,隔离危险代码
  • 在测试中安全执行高风险代码片段,准确率显著提升
  • 适合自动化开发与实时代码执行场景,需谨慎运行

大语言模型在推理、规划和函数调用方面取得突破,多智能体协作框架使其成为软件开发的核心。然而,直接在生产环境中使用其生成的代码存在严重隐患:代码可能不稳定、含漏洞,如数据污染、恶意攻击和幻觉,可能导致系统大规模故障。传统人工审查和安全测试工具在此类场景中不适用或不可靠。本文提出安全转译与执行框架 STELP,可在受控环境下安全执行大模型生成的代码,填补了现有方法在自动化生产系统中的空白。适用于无头代码生成、实时执行代码片段等场景。我们构建了一个经人工验证的不安全代码数据集,并在公开数据集上评估了正确性、安全性和延迟。结果表明,该方法显著优于现有方案,尤其在安全执行高风险代码方面表现突出。注意:本文包含恶意代码片段,运行时需格外谨慎。

原文摘要 · Abstract (English)

Rapid evolution of Large Language Models (LLMs) has achieved major advances in reasoning, planning, and function-calling capabilities. Multi-agentic collaborative frameworks using such LLMs place them at the center of solving software development-related tasks such as code generation. However, direct use of LLM generated code in production software development systems is problematic. The code could be unstable or erroneous and contain vulnerabilities such as data poisoning, malicious attacks, and hallucinations that could lead to widespread system malfunctions. This prohibits the adoption of LLM generated code in production AI systems where human code reviews and traditional secure testing tools are impractical or untrustworthy. In this paper, we discuss safety and reliability problems with the execution of LLM generated code and propose a Secure Transpiler and Executor of LLM-Generated Program (STELP), capable of executing LLM-generated code in a controlled and safe manner. STELP secures autonomous production AI systems involving code generation, filling the critical void left by the impracticality or limitations of traditional secure testing methodologies and human oversight. This includes applications such as headless code generation-execution and LLMs that produce executable code snippets as an action plan to be executed in real time. We contribute a human-validated dataset of insecure code snippets and benchmark our approach on publicly available datasets for correctness, safety, and latency. Our results demonstrate that our approach outperforms an existing method by a significant margin, particularly in its ability to safely execute risky code snippets. Warning: This paper contains malicious code snippets that should be run with caution.

大模型安全代码生成执行防护

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。