Skip to content

Vulnerability Discovery with an Agent, Skills, and Kali

Vulnerability Discovery with an Agent, Skills, and Kali

Section titled “Vulnerability Discovery with an Agent, Skills, and Kali”

Let’s talk security — Xiaozao InfoSec here.

Over the next few posts I’ll record some work on AI-assisted vulnerability discovery, including autonomous agent applications and AI-assisted penetration testing.

The core architecture described in this post is a single agent that pulls in vulnerability-hunting skills via Skills and external tools via MCP — in this case, a Kali system. You give the agent a task and it invokes the relevant tools according to the skill instructions to run the tests.

The overall architecture:

image-20261104160018224

There are plenty of security testing skills available today, such as Anthropic-Cybersecurity-Skills, and several vulnerability-discovery agent tools ship with their own relevant skills — Strix, Artex, PentestGPT, Hexstrike-ai, and others. We can consolidate these skills, or adapt them to our own needs.

First you need an agent that can load skills. Taking Claude Code as an example, put your curated skills in the designated directory — I use the project-level skill directory (project folder\.claude\skills\) to make testing easier.

With the skills ready, we hook up Kali. When a skill mentions a particular tool, or the agent needs a security tool, it can invoke the tools in Kali directly.

There are two ways to connect: through MCP, or by having the agent operate Kali over SSH.

Let’s look at the first. Using Kali’s official MCP as an example, first install the MCP service in Kali:

sudo apt install mcp-kali-server

Then start the MCP:

kali-server-mcp --ip 0.0.0.0 --port 5000

The ip parameter sets the listening address; four zeros allow connections from any IP.

image-20261104161236478

Back in Claude, create a .mcp.json in the current project — project-level MCP servers must be configured in this file. Example contents:

{
"mcpServers": {
"mcp-kali-server": {
"command": "ssh",
"args": [
"mcp-server"
],
"type": "stdio"
}
}
}

That’s one approach. The other is simpler: just tell the agent to connect to Kali remotely over SSH and invoke the tools that way. The drawback of this form is that both the commands executed and their output have to be assembled and interpreted entirely by the model, whereas MCP returns structured JSON.

Once inside Claude, run /mcp and /skills to view the available skills and tools. Once both are recognized, your AI penetration-testing console is essentially set up.

Having an agent with a skill library and tools connected doesn’t mean you can just start testing. Handing a target straight to the agent and telling it to run security tests based on the skill library clearly won’t work well — there are a number of problems:

  1. How does the agent know which skill to invoke for a given feature? For example, there’s a search feature in the admin panel, and the search keyword is rendered on the page. That could mean SQL injection, XSS, or unauthorized access; the query might return employee records, and sensitive fields in the response might not be masked, meaning information disclosure. How does the agent make sure it invokes all these skills?

  2. The testing process is hard to trace. Which endpoints did the agent test? Which vulnerability types did it check on each endpoint? Did it skip any endpoint? This is essentially a black box.

  3. When tools or web responses return a lot of data, feeding all of it into the next step burns a great deal of unnecessary tokens.

  4. Will each vulnerability’s specific testing method stay in bounds? Which operations are sensitive? You want to avoid a security test causing a security incident. So it’s worth reviewing the skill content to see whether it includes exploitation steps — and you can add instructions to the skill stating that it should only probe and must not carry out the corresponding dangerous actions.

So the workflow isn’t fixed. It’s like developing a vulnerability-discovery agent: you need to constrain and plan the process through code, loop mechanisms, prompts, and so on. We therefore need to design the workflow based on how we actually test.

That said, none of this is a showstopper — it doesn’t prevent you from testing. Based on the issues above, I had AI write two prompts in two stages. The first stage does information gathering: target details, the target’s features, endpoints, and the vulnerabilities each endpoint might have — in effect, threat modeling for the record. The second stage has the agent use the stage-one output to invoke the relevant skills for testing, and finally produce a results report.

For reference:

Stage one:

You are an application security analyst with access to the currently connected security Skills and
Kali MCP tools.
Execute stage one: information gathering and threat modeling. This stage only gathers information;
it does not perform vulnerability testing.
### Tasks
1. Within the user-authorized target scope, gather the target's tech stack, services, pages, API
endpoints, HTTP methods, and parameters.
2. Map out the main features, inputs and outputs, authentication methods, user roles, permission
boundaries, and core business flows.
3. Analyze potential risks based on each feature's actual characteristics, not merely its name.
4. Match each feature against the vulnerability types and security Skills that may apply. For
example, a search feature must separately consider SQL injection, XSS, broken access control,
and sensitive information disclosure — do not ignore other risks just because one doesn't apply.
5. Distinguish confirmed facts, inferences, and unknowns. Explain the rationale for each risk
match; mark items with insufficient evidence as pending confirmation.
### Skill Matching Requirements
Filter candidate Skills based on their names, purposes, applicable conditions, and prerequisites.
This stage only matches; it does not perform vulnerability testing.
Do not force matches with irrelevant Skills, and do not omit risk types that are clearly relevant to
a feature's characteristics.
### Token Optimization
Prefer structured summaries over dumping large volumes of page source, scan logs, and request/
response data. Retain the necessary evidence IDs so raw content can be reviewed later on demand.
### Final Output
Produce the following:
1. **Target profile:** tech stack, services, and major components.
2. **Feature and endpoint inventory:** each endpoint's ID, address, method, parameters, function,
and associated permissions.
3. **Feature risk list:** the vulnerability types each feature may involve, with the reasoning.
4. **Skill match list:** recommended Skills, matching rationale, and prerequisites.
5. **Information gaps:** items not yet discovered, unconfirmed, or uncovered.
6. **Stage-two input:** consolidate the above into concise, structured JSON for direct use in the
next stage.
Ensure every endpoint and risk has a unique ID so it can be tracked later.
Stop after completing stage one. Do not perform vulnerability testing.

Stage two:

You are an application security test engineer with access to the currently connected security Skills
and Kali MCP tools.
Based on the stage-one information gathering results and threat model, execute stage two: select the
applicable Skills and perform targeted security probing against the target.
### Execution Flow
1. Read the stage-one report to understand each feature, endpoint, potential risk, and the
corresponding candidate Skills.
2. Select Skills based on actual evidence. Before invoking a Skill, read its instructions to confirm
the applicable conditions, prerequisites, and probing methods.
3. Assess the applicable vulnerability types for each endpoint separately — don't test only one risk,
and don't mechanically run every Skill against every endpoint.
4. Probe according to the methods and constraints defined by each Skill. Only probe and perform the
necessary non-destructive validation; do not exploit vulnerabilities.
5. Adjust subsequent tasks dynamically based on test results. If new risks are found, add test tasks;
if a Skill doesn't apply or its prerequisites aren't met, record the reason and skip it.
6. Verify evidence further for suspected vulnerabilities. Tool errors, anomalous responses, or a
single result must not be treated as a confirmed vulnerability.
### Test Tracking
Create a test record for each endpoint, capturing at minimum:
- Endpoint ID, address, and HTTP method.
- Vulnerability types that should be checked.
- The Skills actually invoked.
- Test status: not tested, in progress, completed, suspected finding, blocked, or skipped.
- Test results, evidence IDs, and reasons for anything incomplete.
Update the record immediately after completing each test. Before finishing, compare the test records
against the stage-one endpoint inventory and explicitly state which endpoints and vulnerability types
were tested, which were not, and why.
Completed tests do not mean the endpoint is necessarily secure.
### Token Optimization
Summarize, deduplicate, and redact tool output as necessary before passing it on — only send the model
the information needed for the current decision.
Retain evidence IDs for original requests, responses, and logs; only read the raw content when you
encounter a suspected vulnerability, an anomaly, or something requiring further validation. Do not
repeatedly pass complete historical logs.
### Final Report
Output:
1. **Confirmed issues:** vulnerability type, impact, evidence, and remediation recommendations.
2. **Suspected issues:** symptoms, existing evidence, and what still needs confirmation.
3. **Test records:** which vulnerability types were tested for each endpoint, which Skills were
invoked, and the results.
4. **Coverage gaps:** endpoints and risks not yet tested, with specific reasons.
5. **Execution summary:** Skill invocations, tool failures, information gaps, and next steps.
All conclusions must be backed by evidence. Do not describe untested areas as secure, and do not
claim tests were completed when they were not actually performed.
Begin stage two now.

Of course, I haven’t tested this mechanism extensively yet — much of it is still being tested and refined, so take it as a reference. If you have better ideas, feel free to share them.

Xiaozao InfoSec: focused on cybersecurity, covering agent security, LLM security, vulnerability discovery, red/blue team operations, application security, AI for cybersecurity, and related areas.