Skip to content

Build a CVE agent

Page as Markdown

Build an agent that reads the CISA Known Exploited Vulnerabilities catalog and reports the newest entries.

Build a CVE agent

Build an agent that reads the CISA Known Exploited Vulnerabilities catalog and reports the newest entries.

About this tutorial

Build an agent that keeps watch on the CISA Known Exploited Vulnerabilities (KEV) catalog, the list of vulnerabilities that are being exploited in the wild. Ask it what is new, and it fetches the catalog and reports the latest entries.

The agent needs no extra tool server. Every agent on the kagent harness has a built-in bash tool, and the runtime image includes wget. What the agent does need is permission to leave its sandbox, so you start with an egress policy for www.cisa.gov. For how egress control works, see Egress policies.

Time: about 15 minutes.

Before you begin

If kagent already runs in your cluster, skip these steps.

  1. Install kubectl, helm 3, and kind v0.32.0 or later.

  2. Create a local kind cluster. To use a Kubernetes cluster that you already run, at version 1.37 or later, skip this step.

    kind create cluster --name kagent --image kindest/node:v1.37.0
  3. Set the API key of your model provider, then install the kagent CLI and run it. kagent install sets up the CRDs, Agent Substrate, a development PostgreSQL database, and kagent, and takes a few minutes.

    export OPENAI_API_KEY="your-api-key-here"
    curl -sL https://kagent.dev/install | bash && kagent install
  4. Check that the kagent pods run. Every pod reports Running.

    kubectl get pods -n kagent

Build the CVE agent

Build the agent step by step in the kagent UI, or apply the same resources as YAML and talk to the agent with the kagent CLI.

Open the kagent UI

kagent dashboard

The command forwards the UI to http://localhost:8082 and opens it in your browser. Leave it running while you work.

Allow the agent to reach CISA

The kagent UI creating an egress policy for www.cisa.gov, then an agent named cve-watch that uses it
Figure: Creating the egress policy and the cve-watch agent, sped up
  1. In the sidebar, click Policies, and then click Create egress policy.

  2. In the Name field, enter cisa-kev. Leave the Namespace as kagent.

  3. Under Destination 1, in the Origin field, enter https://www.cisa.gov. Leave Authentication set to None, because the catalog is public.

  4. Click Create policy.

Create the agent

  1. In the sidebar, click Agents, and then click New Agent.

  2. In the Name field, enter cve-watch. Leave the Namespace as kagent, and leave Shared harness set to kagent-default.

  3. In the Template section, select Inline, and fill in the template.

    FieldValue
    Model configurationkagent/default-model-config
    DescriptionReports the newest known exploited vulnerabilities from CISA
  4. In the System prompt field, enter the following prompt.

    You track the CISA Known Exploited Vulnerabilities (KEV) catalog.
    To read the newest entries, run this command with the bash tool:
    wget -qO- https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json | head -n 400
    The catalog lists the newest entries first. Never answer from memory. Always fetch the catalog first.
    For each vulnerability, report the CVE ID, the vendor and product, the date added, the due date, and whether it is used in ransomware campaigns.
    If the command fails, say so and show the error.

    The prompt gives the agent the exact command, for two reasons. The catalog is a large JSON file with the newest entries at the top, so head keeps the answer within what the bash tool returns. And a model that is told to always fetch does not answer from what it remembers, which is out of date for this kind of question.

  5. From the Egress policies list at the end of the form, choose cisa-kev. Without the policy, the agent cannot reach the catalog.

  6. Click Create agent, and then click Refresh until the agent is Ready.

Ask what is new

  1. Click the agent name, cve-watch, to open its chat page.

  2. Ask a question, such as What did CISA add to the catalog this week?

The conversation shows the bash tool call that fetches the catalog, and then the agent’s summary of the newest entries.

Get a daily report

To have the agent report without being asked, put it on a schedule.

  1. In the sidebar, click Schedules, and then click New Schedule.
  2. From the Agent list, choose kagent/cve-watch, and name the schedule kev-daily.
  3. Leave Repeat set to Daily, and in the Prompt field, enter List the vulnerabilities that CISA added in the last seven days.
  4. Click Create schedule.

Each run leaves its report in a conversation that you open from the schedule’s Execution history.

Verify the agent

  1. Check that the agent is ready.

    kubectl get agent cve-watch -n kagent

    Example output:

    NAME        READY   AGE
    cve-watch   True    5m
    
  2. Check that kagent applied the egress policy to the agent.

    kubectl get agent cve-watch -n kagent \
      -o jsonpath='{range .status.conditions[?(@.type=="EgressPoliciesApplied")]}{.status} {.reason}{end}'

    Example output:

    True Applied
    
  3. Check the agent’s answer to your question. The conversation shows a bash call to wget before the summary, and the summary lists CVE IDs with the dates that CISA added them.

What you built

An agent that fetches a public catalog through an egress policy and reports what is new. Along the way, you used these features:

FeatureWhat you didRead more
Egress policiesAllowed the agent to reach https://www.cisa.gov and nothing elseEgress policies
Built-in toolsThe agent fetched the catalog with its bash tool, without a tool serverSkill tools and built-in tools
Scheduled runsOptionally ran the agent every dayScheduled runs

Clean up

  1. If you created the kev-daily schedule, delete it. In the kagent UI, click Schedules, and delete kev-daily. If you created it with grpcurl, see Scheduled runs for the DeleteScheduledRun call.

  2. Delete the agent and the egress policy.

    kubectl delete agent cve-watch -n kagent
    kubectl delete egresspolicy cisa-kev -n kagent

Next steps