Abstract
Automatic Exploit Generation (AEG) is a critical task in offensive security, traditionally hampered by the limitations of symbolic execution and rigid templates. While Large Language Models (LLMs) demonstrate significant potential in code generation, their application to binary exploitation is restricted by context window constraints, precision requirements, and logic gaps in modeling low-level memory states. This paper presents PwnGPT, a modular framework that transforms LLMs into autonomous security researchers. By integrating static analysis for context pruning, role-play prompting for exploit planning, and an iterative verification module for error correction, PwnGPT significantly enhances the success rate of AEG. Our evaluation on a benchmark of 19 diverse Capture The Flag (CTF) challenges shows that PwnGPT increases the exploit completion rate of OpenAI’s o1-preview from 26.3% to 57.9%.
Introduction
The "holy grail" of offensive security is the ability to automatically identify vulnerabilities and generate functional exploit scripts. Traditional AEG systems often struggle with the creative logic required for modern exploits, particularly when dealing with complex attack chains. LLMs offer a new paradigm but face hurdles: decompiled code is often too large for context windows, and exploits require byte-perfect precision. PwnGPT addresses these challenges by decomposing the exploitation process into manageable, specialized modules.
The PwnGPT Framework
PwnGPT utilizes a three-pillar architecture to guide LLMs through the exploitation lifecycle:
- Analysis Module: To overcome context window limitations, this module employs static analysis to prune decompiled code. It identifies "key functions" (e.g., those near
mainor with high-risk names) and provides the LLM with a distilled representation of the program's logic and security mitigations (e.g., NX, Stack Canaries). - Generation Module: This module uses "role-play prompting" to frame the LLM as a CTF expert. It leverages Chain-of-Thought (CoT) reasoning to develop a step-by-step exploit plan before generating Python code using the
pwntoolslibrary. - Verification Module: The framework attempts to execute the generated exploit in a controlled environment. If execution fails, the resulting traceback and error messages are fed back into the LLM, enabling it to reflect on the failure and iteratively refine the exploit.
Evaluation and Results
The researchers evaluated PwnGPT using a benchmark of 19 challenges covering stack overflows, format string vulnerabilities, integer overflows, and heap exploitation. Models tested included GPT-4o, OpenAI o1-preview, and the Qwen series.
The results demonstrate that PwnGPT provides a substantial performance boost across all models. For instance, the success rate for OpenAI o1-preview jumped from 26.3% to 57.9%, while GPT-4o saw an increase from 21.1% to 36.8%. The iterative verification module proved essential, as models frequently corrected their own logic after observing execution errors.
Key Insights
- Reasoning Models are Superior: Reasoning-focused models like o1-preview significantly outperform standard chat models in AEG. Notably, o1-preview was the only model capable of identifying and exploiting integer overflow vulnerabilities.
- Context Pruning is Essential: Directly feeding large decompiled files to LLMs introduces excessive noise. Static analysis-driven pruning ensures the model focuses on security-critical code paths.
- The Heap Challenge: Despite the framework's success, heap exploitation remains a significant hurdle. The abstract nature of dynamic memory management is currently difficult for LLMs to model without real-time debugging integration.
Conclusion
PwnGPT demonstrates that combining LLMs with traditional static analysis and iterative feedback can dramatically improve automatic exploit generation. While challenges like heap exploitation and stripped binaries remain, the framework provides a robust foundation for future autonomous security research. Future work will explore the integration of Retrieval-Augmented Generation (RAG) and live debugging environments to further bridge the gap between LLM reasoning and low-level memory states.
Summary updated