← Back to Paper List

ZeroLeak: Using LLMs for Scalable and Cost Effective Side-Channel Patching

M. Caner Tol, Berk Sunar
Worcester Polytechnic Institute
arXiv (2023)
Agent Benchmark Reasoning

📝 Paper Summary

Automated program repair (APR) Security patching with LLMs
ZeroLeak is an automated framework that uses Large Language Models and feedback from dynamic analysis tools to iteratively detect and patch microarchitectural side-channel vulnerabilities in cryptographic code.
Core Problem
Security-critical software often contains microarchitectural side-channel vulnerabilities (like timing leaks and Spectre gadgets) because manual patching requires scarce expert knowledge and existing tools are insufficient.
Why it matters:
  • Millions of users rely on open-source crypto libraries (e.g., OpenSSL) that lack resources to fix low-level leaks, leaving systems vulnerable to key extraction.
  • Existing compiler-based mitigations for Spectre often introduce high performance overhead (up to 10x slower) or fail to address all gadget variations.
  • Developers frequently ignore constant-time verification tools due to complexity, leading to unpatched vulnerabilities in production environments.
Concrete Example: A developer writes a cryptographic comparison function `if (a[i] != b[i]) return false;`. This creates a timing side-channel where execution time reveals the index of the first mismatch. ZeroLeak detects this and uses an LLM to rewrite it into a constant-time bitwise operation implementation.
Key Novelty
Iterative LLM-based patching loop with side-channel feedback
  • Combines zero-shot LLM code generation with specific prompts derived from dynamic analysis tools (Microwalk, Spectector) to localize and fix leaks.
  • Uses a feedback loop where the LLM attempts to patch code, the tool verifies it, and failure reports (syntax errors or remaining leaks) are fed back to the LLM for re-patching.
  • Adopts a divide-and-conquer strategy to generate complex crypto algorithms function-by-function to stay within LLM token limits.
Architecture
Architecture Figure Figure 4
The ZeroLeak framework workflow illustrating the iterative patching process.
Evaluation Highlights
  • GPT-4 successfully patched 97% of all leakage points (32 out of 33) across a microbenchmark of vulnerable C code, costing only $1.34 total.
  • Patches generated by GPT-4 for Spectre v1 gadgets incur up to 10x less overhead compared to the standard `clang` compiler's `lfence` mitigation.
  • GPT-3.5 fixed 62% of leakage points, significantly trailing GPT-4's performance but at ~19x lower cost.
Breakthrough Assessment
8/10
Significantly advances automated repair for security-critical hardware vulnerabilities, achieving high success rates and lower overhead than compiler baselines, though currently tested on microbenchmarks rather than large codebases.
×