TL;DR
This paper introduces CTF-KNOW, a new benchmark to specifically measure Large Language Models' (LLMs) technical knowledge in Capture-the-Flag (CTF) cybersecurity challenges. They then propose CTFAGENT, a framework that uses a novel two-stage Retrieval-Augmented Generation (RAG) and interactive environment to significantly improve LLMs' ability to solve these challenges, achieving human-competitive performance.
What Problem Does This Paper Address?
Capture-the-Flag (CTF) competitions are a vital part of cybersecurity education and training, simulating real-world vulnerabilities. As LLMs become more capable, there's a growing interest in their potential to automate CTF challenge solving. However, existing benchmarks often evaluate LLMs' overall performance without deeply understanding their core technical knowledge, which is crucial for success. This paper aims to bridge this gap by first precisely measuring LLMs' CTF technical knowledge and then developing a system to augment their capabilities for better performance in CTF environments.
Methods
The authors developed a five-phase process to create their benchmark, CTF-KNOW:
- Write-up Collection: Gathered over 1,000 CTF write-ups from major competitions.
- CTF Knowledge Extraction: Used GPT-4 to extract technical knowledge points (scenario, exploit method, example payload) from these write-ups.
- Knowledge Filtering: Employed another LLM (Deepseek) to filter out potential hallucinations and ensure the extracted knowledge was accurate.
- Question Generation: Created both single-choice and open-ended questions based on the filtered knowledge to test LLMs' understanding and application.
- Question Filtering & Manual Verification: Further refined questions and manually verified a subset to ensure high quality.
Based on these findings, they proposed CTFAGENT, a framework that enhances LLMs for CTF solving. CTFAGENT has two core modules:
- Two-stage Retrieval-Augmented Generation (RAG): This module provides LLMs with relevant technical knowledge at different stages. "DB-Understanding" helps identify vulnerabilities by searching code snippets, while "DB-Exploiting" provides specific exploitation strategies.
- Interactive Environmental Augmentation (EA): This module creates a more dynamic and user-friendly CTF environment for LLMs, integrating interactive commands and advanced tools (like IDA Pro for decompilation) to better mimic human interaction and overcome limitations of static environments.
Datasets
- CTF Write-ups: Over 1,000 write-ups from major CTF competitions (e.g., DEFCON, HITCON, GoogleCTF, UIUCTF) collected from CTFtime.
- CTF-KNOW Benchmark: A newly constructed benchmark with 3,992 questions (1,996 single-choice and 1,996 open-ended) derived from the collected write-ups.
- Evaluation Datasets:
- Intercode-CTF: 100 CTF challenges from the picoCTF platform.
- NYU CTF Dataset: 200 CTF challenges from the CSAW competition.
- Real-world Competition: picoCTF2024 was used to evaluate CTFAGENT's practicality.
Key Insights and Ideas
- LLMs have strong technical knowledge, but struggle with application: While LLMs can recall a vast amount of CTF technical knowledge (high accuracy on single-choice questions), they falter when asked to apply it to specific, open-ended scenarios. This highlights a critical gap between knowing and doing.
- CTF environments are a major bottleneck: LLMs struggle not just with knowledge but also with interacting with the CTF environment. Issues like missing tools, permission errors, and the inability to handle real-time feedback significantly hinder their performance.
- RAG and interactive environments are crucial augmentations: The proposed CTFAGENT framework, by providing targeted knowledge (RAG) and a better interaction interface (EA), dramatically improves LLM performance, suggesting these are key to unlocking LLMs' potential in CTF.
- Challenge difficulty matters: LLM performance degrades as CTF challenge difficulty increases, especially in matching technical knowledge to complex scenarios.
- CTFAGENT shows human-competitive performance: The framework not only outperforms previous LLM-based CTF solvers but also achieves a ranking within the top 23.6% of human teams in a real-world competition.
Key Results
- CTF-KNOW Measurement: LLMs achieved over 70% accuracy on single-choice CTF technical knowledge questions, demonstrating strong recall. However, accuracy dropped to around 30-50% for open-ended questions, showing poor application ability.
- CTFAGENT Performance:
- On Intercode-CTF, CTFAGENT improved LLM performance by 85% (from 39% to 73% accuracy).
- On NYU CTF Dataset, CTFAGENT achieved over 120% improvement.
- In picoCTF2024, CTFAGENT ranked in the top 23.6% of nearly 7,000 teams.
- Ablation Study: Both the RAG and EA modules were essential for CTFAGENT's success; removing either significantly degraded performance.
- Human vs. LLM Comparison: CTFAGENT demonstrated human-competitive performance, even outperforming human participants in Crypto and Reverse categories, though it lagged in Misc and Web challenges due to tool limitations.
Limitations and Future Work
- RAG Misguidance: The RAG system can sometimes retrieve inaccurate or irrelevant knowledge, misguiding the LLM. Future work could involve expanding the dataset and improving retrieval accuracy.
- Lack of Multi-modal Capabilities: CTFAGENT currently lacks the ability to process visual information, limiting its effectiveness in challenges like OSINT or those involving GUIs. Integrating multi-modal LLMs is a key future direction.
- Reasoning Enhancement: While CTFAGENT improves knowledge application, further strengthening the LLM's core reasoning capabilities for complex, multi-turn interactions and tool integration is needed. Techniques like Tree of Thoughts (ToT) or Reinforcement Learning are suggested.
- Ethics: The authors acknowledge the potential for misuse of CTFAGENT for unauthorized attacks. They propose releasing CTFAGENT under a review process and advocate for continued research into safeguards for LLMs in offensive security.
- Tool Limitations: CTFAGENT's performance in Misc and Web challenges is limited by its current toolset, particularly its inability to effectively use GUI-based tools like Burp Suite.
Summary updated