Abstract
In recent years, large language models (LLMs) have become increasingly capable and can now interact with tools (i.e., call functions), read documents, and recursively call themselves. As a result, these LLMs can now function autonomously as agents. With the rise in capabilities of these agents, recent work has speculated on how LLM agents would affect cybersecurity. However, not much is known about the offensive capabilities of LLM agents. In this work, we show that LLM agents can autonomously hack websites, performing tasks as complex as blind database schema extraction and SQL injections without human feedback. Importantly, the agent does not need to know the vulnerability beforehand. This capability is uniquely enabled by frontier models that are highly capable of tool use and leveraging extended context. Namely, we show that GPT-4 is capable of such hacks, but existing open-source models are not. Finally, we show that GPT-4 is capable of autonomously finding vulnerabilities in websites in the wild. Our findings raise questions about the widespread deployment of LLMs.
Introduction
While the cybersecurity community has long speculated that Large Language Models (LLMs) could be used to generate malware or phishing emails, most previous research focused on LLMs as assistants to human hackers. This research explores a more concerning evolution: autonomous agents. The study addresses whether an LLM can act as a "black-box" attacker—given only a URL and no prior knowledge of the site's vulnerabilities—to find and exploit security flaws. This requires the model to not only write code but also to navigate a browser, interpret server responses, manage long-term state, and pivot its strategy when an initial attempt fails.
Agent Architecture and Methodology
The researchers constructed an autonomous hacking agent using a streamlined stack of approximately 85 lines of code. The architecture integrates several key components to enable autonomous operation.
The core engine utilizes GPT-4 (via the OpenAI Assistants API) for planning and state management. The agent is equipped with a suite of tools, including a headless browser (Playwright) for website interaction, a terminal (curl), and a Python code interpreter. To augment its capabilities, the agent can retrieve information from a knowledge base consisting of six publicly available documents covering common web attack vectors like SQL injection and XSS. A specialized prompting strategy encourages creativity and backtracking, allowing the agent to recursively call itself and its tools until a goal is achieved or a time limit is reached.
Experimental Setup: The Vulnerability Benchmark
The study utilized a custom-built benchmark of 15 web vulnerabilities hosted on sandboxed, real-world-style websites. These vulnerabilities ranged from "Easy" (e.g., LFI, CSRF, simple SQL Injection) to "Hard" (e.g., Hard SQL Union, SSRF). For instance, a "Hard SQL Union" attack required the agent to first extract the database schema blindly before performing the final data exfiltration. Beyond the sandbox, the agent was tested on 50 "in the wild" websites, where it successfully identified a Cross-Site Scripting (XSS) vulnerability.
Key Results and the "Frontier Gap"
The experimental results reveal a stark "capability gap" between frontier models and their predecessors or open-source counterparts.
GPT-4 achieved a 73.3% success rate (Pass@5) across the 15 vulnerabilities, successfully performing complex exploits like 38-step "Hard" SQL union attacks. In contrast, GPT-3.5 showed significantly lower performance (6.7% success), and every open-source model tested—including Llama-2 70B and Mixtral 8x7B—failed to exploit a single vulnerability. This suggests that autonomous hacking is an emergent property appearing only in the most advanced models.
Insights and Economic Implications
The study highlights that planning, rather than raw knowledge, is the primary bottleneck for autonomous hacking. Open-source models often failed due to reasoning errors or incorrect tool usage, whereas GPT-4 demonstrated sophisticated multi-step planning and error recovery. Furthermore, Retrieval-Augmented Hacking (RAH) proved to be a massive force multiplier; removing the hacking documents reduced GPT-4's success rate from 42.7% to 17.3% (on a Pass@1 basis).
The economics of this automation are also significant. The researchers estimated the cost of a successful GPT-4 hack at approximately $9.81. Compared to the estimated $80 cost of hiring a human for a similar task, LLM agents represent an 8x reduction in cost, potentially enabling large-scale "spray and pray" attacks at an unprecedented scale.
Conclusion and Future Directions
While GPT-4 shows remarkable capabilities, it still faces a "hard ceiling" on tasks requiring highly sophisticated reasoning about web state, such as complex Javascript attacks. Future work may involve integrating vision capabilities (multimodal LLMs) to bypass UI-based security and exploring the use of LLM agents for defensive bug hunting and patching. Due to the potential for misuse, specific system prompts and documents used in this study were not publicly released.
Summary updated