Security critical software, e.g., OpenSSL, comes with numerous side-channel leakages left unpatched due to a lack of resources or experts. The situation will only worsen as the pace of code development accelerates, with developers relying on Large Language Models (LLMs) to automatically generate code. In this work, we explore the use of LLMs in generating patches for vulnerable code with microarchitectural side-channel leakages. For this, we investigate the generative abilities of powerful LLMs by carefully crafting prompts following a zero-shot learning approach. All generated code is dynamically analyzed by leakage detection tools, which are capable of pinpointing information leakage at the instruction level leaked either from secret dependent accesses or branches or vulnerable Spectre gadgets, respectively. Carefully crafted prompts are used to generate candidate replacements for vulnerable code, which are then analyzed for correctness and for leakage resilience. From a cost/performance perspective, the GPT4-based configuration costs in API calls a mere few cents per vulnerability fixed. Our results show that LLM-based patching is far more cost-effective and thus provides a scalable solution. Finally, the framework we propose will improve in time, especially as vulnerability detection tools and LLMs mature.
翻译:安全关键软件(如OpenSSL)因缺乏资源或专家而存在大量未修复的侧信道泄露。随着代码开发速度加快,开发人员依赖大语言模型自动生成代码,这一问题将愈发严峻。本研究探索利用大语言模型为存在微架构侧信道泄露的漏洞代码生成补丁。具体而言,我们通过精心设计遵循零样本学习方法的提示词,研究强大语言模型的生成能力。所有生成的代码均由泄漏检测工具进行动态分析,这些工具能够从指令级别精准定位由秘密依赖访问、分支或易受攻击的Spectre组件导致的信息泄露。精心设计的提示词用于生成漏洞代码的候选替换方案,随后对替换方案进行正确性和抗泄漏韧性分析。从成本/性能角度来看,基于GPT4的配置每次修复漏洞的API调用成本仅为几美分。结果表明,基于大语言模型的补丁方案更具成本效益,因此可提供可扩展的解决方案。最后,随着漏洞检测工具和大语言模型的成熟,我们提出的框架将持续改进。