Using AI Penetration Testing on my Custom WAF to Uncover Unprotected and Unmitigated Vulnerabilities

ShannonVsKunato_60percent
ShannonVsKunato_60percent

I initially started building Kunato, my custom WAF (Web Application Firewall), with the casual mindset of “I might as well have a WAF for my own blog.” Since then, I’ve found it interesting to add various features and have been having fun uncovering defensive gaps using penetration testing tools.

In this post, to counter the recent trend of using AI for server intrusion and information gathering, I will use an AI penetration testing tool called Shannon to attack a local server and test whether Kunato can defend it successfully.

(No one is actually going to use AI to break into my blog, but it sounded fun, so I’m doing it.)

Also, it goes without saying that the most important aspects of security measures are security updates and bug fixes for upstream servers and applications.

What is AI-Powered Penetration Testing?

The challenge this time is not a mechanical penetration test, but an AI-powered penetration test.
The difference from mechanical penetration testing lies in the AI’s ability to engage in trial and error. By using information obtained from preliminary research and creating plans to conquer the target, it performs trial and error that is much closer to a human than typical penetration testing tools.

One AI-powered penetration testing tool is shannon, which is released as open source.
The workflow involves specifying an AI model you have a contract with (you can use various models such as Codex, Claude, OpenCode, or DeepSeek) before execution.

Additionally, for the web application that Kunato will protect, I will use DVWA (a test HTTP application intentionally designed with vulnerabilities, composed of PHP+MySQL).
I will conduct this test by running these within WSL on my home PC.

Precautions

AI penetration testing using Shannon must always be performed within your own PC and must never be performed on internet-based services.
Depending on the situation, this could lead to criminal charges or claims for damages.

Furthermore, even on servers hosted on IaaS such as AWS, it is safer not to do it, even if you own the server.
If you absolutely must do it for a legitimate reason, such as business necessity, please consult with the service provider in advance.

Overview and Features of Shannon

Shannon is a penetration testing tool developed by Keygraph that uses AI to automate vulnerability diagnosis for web applications and APIs.
github KeygraphHQ/shannon

Unlike conventional vulnerability scanners, its key feature is that it autonomously executes everything from source code analysis and vulnerability discovery to validation through actual attacks and report generation.

Main Features

- Autonomous Penetration Testing via AI

  • AI agents automate information gathering, vulnerability analysis, attack execution, and result reporting.
  • Minimizes manual operation, allowing for continuous security testing.

- Support for Major Web Vulnerabilities

  • Injection attacks such as SQL injection.
  • Cross-Site Scripting (XSS).
  • Server-Side Request Forgery (SSRF).
  • Improper authentication functions and authentication bypass.
  • Access control and authorization flaws.

- Utilization of Multiple AI Agents

  • Executes processes such as information gathering, code analysis, and vulnerability verification in stages.
  • Integrates multiple analysis results and removes duplicates to narrow down the attack target.

- Automated Security Report Generation

  • Supports PDF, Markdown, JSON, and SARIF formats.
  • Records the details of vulnerabilities and the results of attack verifications.

- Support for Multiple LLMs

  • Supports Anthropic, OpenAI, xAI, AWS Bedrock OpenCode, etc.
  • Local LLM configurations using Ollama, etc., are also possible.
  • Diagnostic accuracy and execution costs vary depending on the LLM used.

- Provided as Open Source

  • The open-source version is available under the AGPL-3.0 license.
  • Can be run in a local environment and supports environment isolation via Docker.
  • Commercial Pro and Enterprise versions are also available.

In short, Shannon is an autonomous penetration testing tool that focuses not just on “finding vulnerabilities” using AI, but on “verifying whether an attack actually succeeds.”

Preparing a Vulnerable Web Server with DVWA

To conduct the test, I intentionally prepared a vulnerable web server behind Kunato.
I used the DVWA application (provided as a Docker image), which is a purposefully vulnerable PHP+MySQL application.
I used how well this vulnerable web service could be defended as a metric for this test.

Test Procedure

This is the procedure to start DVWA (a vulnerable PHP app) in a WSL environment, have Kunato protect it, and perform penetration testing with Shannon.

Clone Kunato:

git clone git@github.com:hiroeorz/kunato.git
cd kunato

Preparing the Vulnerable Server

Start DVWA in a container:

scripts/security-lab.sh shell --config rules-dvwa.yaml --publish 127.0.0.1:18080 --no-shell

Retrieve DVWA source (perform in a separate terminal):
To use with Shannon’s -r option, we extract the source from the image.

docker create --name dvwa-src ghcr.io/digininja/dvwa:latest
docker cp dvwa-src:/var/www/html /tmp/opencode/dvwa-src
docker rm dvwa-src

PHP sources such as vulnerabilities/exec/ will be located in /tmp/opencode/dvwa-src.

Start the gateway relay:

socat TCP-LISTEN:18081,bind=172.17.0.1,fork,reuseaddr TCP:127.0.0.1:18080

Now, traffic from the Shannon worker will reach 172.17.0.1:18081.

Connectivity check:

curl -i 'http://127.0.0.1:18080/vulnerabilities/sqli/?id=1&Submit=Submit' | head

If you receive a 200 status and a “First name”, the vulnerable HTTP server is successfully running.

Initial Setup for Shannon

In this example, I will write the instructions assuming the use of OpenCode’s GLM-5.3.
First, in the OpenCode console, go to “Settings → Service Account → Select Account → Generate new credentials in the Credential section at the bottom of the page.”
Set the generated credentials to the following environment variables and select the model you wish to use.

Since OpenCode’s GLM-5.3 happened to be having a campaign at the time, I decided to use it.

unset SHANNON_USE_PI_AUTH
unset SHANNON_AI_BASE_URL
export SHANNON_AI_API_KEY="oc_xx_xxxxxxx_xxxxxxxxxxxxxxxxxxx"
export SHANNON_AI_MODEL="opencode-go:glm-5.3"

Set your own credentials in SHANNON_AI_API_KEY and the model you want to use in SHANNON_AI_MODEL.

Note that if you are using Codex or Claude, you can set them interactively using:

npx @keygraph/shannon@latest setup

Running Shannon Vulnerability Diagnosis Against DVWA

Now, it’s finally time to let the AI perform the intrusion test.
As mentioned repeatedly, AI penetration testing using Shannon must always be performed within your own PC and must never be performed on internet-based services.
Depending on the situation, this could lead to criminal charges or claims for damages.

npx @keygraph/shannon@latest start -u http://172.17.0.1:18081 -r /tmp/opencode/dvwa-src -w dvwa-lab --follow

Meaning of the options:

-u: Gateway-side relay
-r: Location of the extracted DVWA source
-w: Workspace name (automatically resumes upon re-execution)
-o: If you add `/tmp/opencode/shannon-dvwa`, the report can be copied to the specified location.

Execution will take approximately one hour.

Cost

Shannon itself is free because it is open source.
However, AI tokens are consumed, so you will incur costs for that.
The AI cost varies depending on the model, but in the case of GLM-5.3, I used approximately $53 worth of tokens (about ¥8,480).
However, because OpenCode was running a campaign for GLM-5.3, it easily fit within the OpenCode Go subscription fee.

Results

Result reports are generated in ~/.shannon/workspaces/.
In this test, it was revealed that several RCEs (Remote Code Executions) could not be prevented.
I have already fixed Kunato so that it can defend against these.

As a result, it seems that remote code execution and other methods succeeded in 31 different ways. (The original report is in English. The image below is translated into Japanese using ChatGPT.)

スクリーンショット 2026-11-21 160306
スクリーンショット 2026-11-21 160306

It even provides reports on exactly how each RCE was performed (translated into Japanese using ChatGPT).
In this manner, it summarized each vulnerability and its exploitation procedure in a report of over 60 pages.

スクリーンショット 2026-11-21 160409
スクリーンショット 2026-11-21 160409

Some of these attack methods can be defended or mitigated by a WAF, while others cannot. I will identify the ones that can be defended or mitigated by my custom WAF and address them.

Regardless, it seems like this could really uncover vulnerabilities if deployed against servers on the internet.
But that could be a crime, so I’ll never do it. Please don’t do it.

© 2025 Hiroe Tech Notes. All rights reserved.

Comments

No comments yet.