PenHeal: A Two-Stage LLM Framework for Automated Pentesting and Optimal Remediation
Junjie Huang, Quanyan Zhu
TL;DR
PenHeal presents a two‑stage LLM framework that automates both vulnerability discovery and remediation. By coupling a Pentest Module with a Remediation Module and guiding reasoning with Counterfactual Prompting and an external Instructor knowledge base, it achieves higher vulnerability coverage and more effective, cost‑efficient remediation than baselines on a Metasploitable2 benchmark. The work introduces a concrete evaluation framework with CVSS‑informed remediation scoring and a Group Knapsack optimization to select budget‑constrained actions. Results show a 31% gain in detection coverage, a 32% improvement in remediation effectiveness, and a 46% reduction in remediation costs, signaling substantial practical potential for autonomous cybersecurity workflows. Limitations include tool dependence, multi‑host scalability, and the need for end‑to‑end deployment considerations, which the authors propose addressing in future research.
Abstract
Recent advances in Large Language Models (LLMs) have shown significant potential in enhancing cybersecurity defenses against sophisticated threats. LLM-based penetration testing is an essential step in automating system security evaluations by identifying vulnerabilities. Remediation, the subsequent crucial step, addresses these discovered vulnerabilities. Since details about vulnerabilities, exploitation methods, and software versions offer crucial insights into system weaknesses, integrating penetration testing with vulnerability remediation into a cohesive system has become both intuitive and necessary. This paper introduces PenHeal, a two-stage LLM-based framework designed to autonomously identify and mitigate security vulnerabilities. The framework integrates two LLM-enabled components: the Pentest Module, which detects multiple vulnerabilities within a system, and the Remediation Module, which recommends optimal remediation strategies. The integration is facilitated through Counterfactual Prompting and an Instructor module that guides the LLMs using external knowledge to explore multiple potential attack paths effectively. Our experimental results demonstrate that PenHeal not only automates the identification and remediation of vulnerabilities but also significantly improves vulnerability coverage by 31%, increases the effectiveness of remediation strategies by 32%, and reduces the associated costs by 46% compared to baseline models. These outcomes highlight the transformative potential of LLMs in reshaping cybersecurity practices, offering an innovative solution to defend against cyber threats.
