一句话:提出基于遗传算法的对抗代码混淆框架 Acoda,用 8 种保语义混淆方法诱导 LLM 拒绝或误读代码分析。
随着大语言模型(LLM)广泛应用于代码理解、调试和漏洞检测等软件工程任务,其强大的语义推理能力也带来新的安全与隐私风险:LLM 可分析、重构甚至逆向源代码逻辑,导致知识产权泄露。为此,本文提出 Acoda,一个基于遗传算法的对抗性代码混淆框架,用于防御基于 LLM 的代码分析。Acoda 利用 LLM 的安全对齐机制与基于 token 的信息处理特性,设计了 8 种保持语义的混淆方法,并通过遗传算法迭代优化混淆策略以生成防御效果最大化的对抗样本。此外,作者提出基于 LLM 响应的量化评估框架,结合辅助 LLM 与四个评价指标全面评估目标 LLM 对混淆代码的分析行为。实验表明,在 GPT-4o、DeepSeek、Qwen、Llama、Gemma 等 7 个先进 LLM 上,Acoda 的攻击成功率最高达 70%,具有较强跨模型迁移性且运行时开销很小,同时保证原始代码语义不变。
With the widespread adoption of Large Language Models (LLMs) in software engineering (SE) tasks such as code understanding, debugging, and vulnerability detection, their powerful semantic reasoning ability has also introduced new security and privacy risks. LLMs can analyze, reconstruct, or even reverse-engineer source code logic, potentially leading to the leakage of intellectual property. To address this issue, we propose Acoda, a genetic algorithm–based adversarial code obfuscation framework that defends against LLM-based code analysis. Acoda leverages two key mechanisms of LLMs, namely safety alignment and token-based information processing, to design 8 semantics-preserving obfuscation methods. It iteratively optimizes obfuscation strategies through a genetic algorithm to generate adversarial samples that maximize defensive effectiveness. In addition, we propose a quantitative evaluation framework based on LLM responses, which combines an auxiliary LLM and four evaluation metrics to assess how target LLMs analyze obfuscated code comprehensively. Experimental results show that Acoda can effectively induce LLMs to refuse or misinterpret code analysis. On 7 state-of-the-art LLMs, including GPT-4o, DeepSeek, Qwen, Llama, and Gemma, Acoda achieves an attack success rate (ASR) of up to 70%, with strong cross-model transferability and minimal runtime overhead, while ensuring that the semantics of the original code remain unchanged. Overall, this study provides a new perspective for code protection and LLM security defense in the era of LLMs.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2606-11755,
title = {Acoda: Adversarial Code Obfuscation for Defending against LLM-based Analysis},
author = {Hongzhou Rao and Zikan Dong and Yanjie Zhao and Haodong Li and Haoyu Wang},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3774748.3793624}
}