代码安全团队和开发者面临LLM分析带来的知识产权泄露风险,Acoda提供了一种实用的防御手段,建议关注其混淆方法如何平衡安全性和代码可用性。
Acoda是一种基于遗传算法的对抗性代码混淆框架,旨在防御大语言模型(LLM)对源代码的分析、重构和逆向工程。它利用LLM的安全对齐和基于token的信息处理机制,设计了8种保持语义的混淆方法,并通过遗传算法迭代优化混淆策略。实验表明,Acoda在GPT-4o、DeepSeek、Qwen等7个先进LLM上实现了高达70%的攻击成功率,且具有跨模型迁移性和低运行时开销。这项工作为代码保护和LLM安全防御提供了新视角。
Acoda: Adversarial Code Obfuscation for Defending against LLM-based Analysis
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.