Development of an n8n-Based Automated Framework for Penetration Testing Using Large Language Models and Structured Evidence

Main Article Content

Annop Monsakul

Abstract

This research aims to develop and evaluate an evidence-driven automated framework for penetration testing by integrating large language models with hallucination-aware verification. The proposed framework addresses key limitations of traditional penetration testing, including heavy reliance on expert analysts, fragmented use of multiple security tools, heterogeneous tool outputs, and inconsistent results across repeated testing cycles. The framework employs n8n as the central workflow orchestration platform within a Docker container stack. It classifies assessment targets into four categories: network service systems, modern web applications, API security systems, and systems involving secret leakage or insecure configuration. Based on the target category, the framework selects an appropriate testing strategy, collects outputs from relevant security assessment modules, transforms them into structured evidence, and stores them in a PostgreSQL database. GPT-4o is then used through prompt engineering and structured output, without model fine-tuning, to support vulnerability interpretation, evidence correlation, and risk prioritization. To reduce the risk of unsupported or hallucinated findings, the framework incorporates a hallucination-aware verification mechanism requiring every reported finding to be supported by tool-generated evidence or execution logs before inclusion in the final report. The experiment was conducted using four deliberately vulnerable systems: Metasploitable3, OWASP Juice Shop, OWASP crAPI, and OWASP WrongSecrets. Each target was tested six times, resulting in 24 campaign runs. The experimental results indicate that the proposed framework consistently collected structured evidence, achieving structured-evidence consistency above 97% across all targets. The verification pass rate of LLM-generated findings ranged from 83.02% to 90.32%, while the average traceability score ranged from 89.83% to 96.83%. These results suggest that combining workflow automation, structured evidence management, and evidence-based verification of large language model outputs can improve the reliability, consistency, and traceability of automated penetration testing.

Article Details

Section
Research Article

References

OWASP API Security Project Team. “OWASP Top 10 API Security Risks – 2023.” OWASP.org. Accessed: May 22, 2026. [Online]. Available: https://owasp.org/API-Security/editions/2023/en/0x11-t10/

OWASP Foundation. OWASP Web Security Testing Guide v4.2. (2020). Accessed: May 22, 2026. [Online]. Available: https://owasp.org/www-project-web-security-testing-guide/

OWASP Foundation, “OWASP Top Ten Web Application Security Risks,” 2025. [Online]. Available: https://owasp.org/www-project-top-ten/

Forum of Incident Response and Security Teams, “Common Vulnerability Scoring System Version 4.0: Specification Document,” Document Version 1.2, Nov. 1, 2023. [Online]. Available: https://www.first.org/cvss/v4-0/cvss-v40-specification.pdf

Metasploitable3. (2025). GitHub repository. Rapid7, Inc. Accessed: May 22, 2026. [Online]. Available: https://github.com/rapid7/metasploitable3

G. Lyon, Nmap Network Scanning. Beaverton, OR, USA: Nmap Software, 2009. Accessed: May 22, 2026. [Online]. Available: https://nmap.org/book/toc.html

Metasploit Framework. GitHub repository. Rapid7, Inc. Accessed: May 22, 2026. [Online]. Available: https://github.com/rapid7/metasploit-framework

B. Kimminich et al. OWASP Juice Shop. (2026). GitHub repository. (v20.1.1). OWASP. Accessed: Jul. 18, 2026. [Online]. Available: https://github.com/juice-shop/juice-shop

ZAP Dev Team. “Documentation.” ZAPROXY.org. Accessed: May 22, 2026. [Online]. Available: https://www.zaproxy.org/docs/

OWASP Foundation. “OWASP crAPI.” OWASP.org. Accessed: May 22, 2026. [Online]. Available: https://owasp.org/www-project-crapi/

J. Willemsen et al. OWASP WrongSecrets. (2026). OWASP. Accessed: May 22, 2026. [Online]. Available: https://owasp.org/www-project-wrongsecrets/

G. Deng et al., “PentestGPT: Evaluating and harnessing large language models for automated penetration testing,” in Proc. 33rd USENIX Secur. Symp., Philadelphia, PA, USA, Aug. 2024, pp. 847–864.

R. Fang, R. Bindu, A. Gupta, Q. Zhan, and D. Kang, “LLM agents can autonomously hack websites,” 2024, arXiv:2402.06664.

M. Bhatt et al., “CyberSecEval 2: A wide-ranging cybersecurity evaluation suite for large language models,” 2024, arXiv:2404.13161.

S. Wan et al., “CYBERSECEVAL 3: Advancing the evaluation of cybersecurity risks and capabilities in large language models,” 2024, arXiv:2408.01605.

P. Jing et al., “SecBench: A comprehensive multi-dimensional benchmarking dataset for LLMs in cybersecurity,” 2024, arXiv:2412.20787.

N. Tihanyi, M. A. Ferrag, R. Jain, T. Bisztray, and M. Debbah, “CyberMetric: A benchmark dataset based on retrieval-augmented generation for evaluating LLMs in cybersecurity knowledge,” in Proc. IEEE Int. Conf. Cyber Secur. Resilience (CSR), London, U.K., Sep. 2024, pp. 296–302.

I. David and A. Gervais, “Multi-agent penetration testing AI for the web,” 2025, arXiv:2508.20816.

X. Wu et al., “CurriculumPT: LLM-based multi-agent autonomous penetration testing with curriculum-guided task scheduling,” Appl. Sci., vol. 15, no. 16, 2025, Art. no. 9096, doi: 10.3390/app15169096.

N. O. Jaffal, M. Alkhanafseh, and D. Mohaisen, “Large language models in cybersecurity: A survey of applications, vulnerabilities, and defense techniques,” AI, vol. 6, no. 9, 2025, Art. no. 216, doi: 10.3390/ai6090216.

OpenAI. “GPT-4o system card.” OPENAI.com. Accessed: May 22, 2026. [Online]. Available: https://openai.com/index/gpt-4o-system-card/

Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile, NIST AI 600-1, National Institute of Standards and Technology, Gaithersburg, MD, USA, Jul. 2024. [Online]. Available: https://doi.org/10.6028/NIST.AI.600-1

National Institute of Standards and Technology, “The NIST Cybersecurity Framework (CSF) 2.0,” Gaithersburg, MD, USA, NIST CSWP 29, Feb. 2024. [Online]. Available: https://doi.org/10.6028/NIST.CSWP.29

OWASP, “OWASP Top 10 for LLM Applications 2025,” OWASP Found., Wilmington, DE, USA, Accessed: May 22, 2026. [Online]. Available: https://genai.owasp.org/resource/owasp-top-10-for-llm-applications-2025/

n8n. “AI Workflow Automation Platform.” N8N.io. Accessed: May 22, 2026. [Online]. Available: https://n8n.io/

Docker Inc. Docker Compose. (2026). Accessed: May 22, 2026. [Online]. Available: https://docs.docker.com/compose/

Grafana Labs. “Dashboards.” GRAFANA.com. Accessed: May 22, 2026. [Online]. Available: https://grafana.com/docs/grafana/latest/visualizations/dashboards/