Automated Penetration Testing with PentestGPT: Open-Source Agent Framework
A new open-source framework for automated penetration testing has emerged, leveraging large language models to execute security assessments with minimal human intervention.
Framework Overview
PentestGPT operates by directing a language model toward a target system and allowing it to autonomously perform reconnaissance, exploitation, and post-exploitation tasks. In its standard configuration, the process follows a sequence: initial reconnaissance, followed by exploitation, and concluding with a walkthrough phase. When activated in pentest mode, the workflow shifts to asset discovery, vulnerability identification, and report generation, with no manual oversight required.
Integration and Tools
The framework integrates with Claude Code and Codex, utilizing their capabilities to execute commands, run security tools, and dynamically determine next steps based on real-time feedback. The initial version of the project was introduced by Gelei Deng and collaborators at the USENIX Security 2024 conference.
Deployment Requirements
To deploy PentestGPT, users must install Python 3.12 or later, the uv package manager, and two authenticated command-line tools: Claude Code and Codex. A Docker image simplifies setup by bundling both command-line interfaces, enabling users to log in once, with authentication tokens stored in persistent volumes. This approach ensures that login credentials remain intact even after container recreation.
Codex Authentication Considerations
A critical consideration for first-time users is the handling of Codex authentication. Unlike some platforms, ChatGPT’s refresh tokens are single-use, necessitating an OAuth callback mechanism via socat. This configuration is essential for building custom images for team environments.
Legacy Version and Human-in-the-Loop Mode
A legacy version of the tool, pentestgpt-legacy, remains available for users requiring a human-in-the-loop approach. This mode employs three concurrent large language model sessions—reasoning, generation, and parsing—to maintain a Pentesting Task Tree while allowing interactive control.
Model Provider Support
The human-in-the-loop mode supports a broader range of model providers compared to the autonomous pipeline, including OpenAI, Anthropic, Google Gemini, DeepSeek, xAI, Qwen, Moonshot, and local models through Ollama.
Model Registry and Smoke Test
The model registry, verified as of June 2026, acknowledges that model identifiers can become outdated. A built-in smoke test evaluates all configured models in real-time, generating a pass/fail matrix to validate functionality before deployment.
Data Collection Practices
Data collection practices are explicitly outlined. By default, PentestGPT transmits anonymous usage metrics to a Langfuse project, including session metadata such as target type, duration, completion status, tools executed, and whether a flag was discovered. However, sensitive information like command outputs, credentials, and flag values is not transmitted. This distinction is critical for compliance, as legal counsel for clients would prioritize such details.
Opting Out of Data Collection
Users can opt out of data collection via a command-line flag or environment variable.
Availability and Purpose
The framework is freely available on GitHub, offering developers and security professionals an open-source platform for automated penetration testing. Its design emphasizes flexibility, scalability, and integration with existing security toolchains, while maintaining strict controls over data privacy and model interoperability.
