Skip to content

Use

User guide

How to point AgentKavach Scan at your own agent, get trustworthy results, and use them in CI.

Scan only targets you own or have written permission to test (responsible-use.md).

0. The easiest way in: the app

# Pre-alpha, not on PyPI yet: from a checkout, `uv sync --extra ui`, then
uv run agentkavach ui

After the first release: pip install 'agentkavach[ui]' then agentkavach ui.

It starts a server on your own machine (127.0.0.1 only) and opens your browser. Each session has a random token; the link printed in the terminal includes it. If you see “missing or wrong session token”, reopen that link.

  • Overview: run the demo in one click, or start the wizard.
  • New scan (wizard): six steps, each with a “why we ask” note.
    1. Name the target and choose how to reach it.
    2. Connection details. For the API key, enter only the name of an environment variable. The app tells you whether it is set, and never shows or stores the value.
    3. Authorization. You must confirm you own the target or have written permission. It is never pre-ticked and cannot be skipped.
    4. What to observe. A live meter shows how many of the scenarios your setup can measure and what each addition would unlock (a planted marker, canary seeding, an indirect channel, a judge). “Test connection” sends one greeting.
    5. Languages and limits. English stays selected because it is the baseline for the language gap.
    6. Review: a dry-run plan (nothing is sent), skipped scenarios with reasons, and the config as YAML. Then save, or save and run.
  • Run view: progress, model calls against your estimate or budget, canary alerts, the latest transcript, and a Cancel button. Cancelling keeps partial results.
  • Report: the grade and why, the language-gap table, findings with filters (severity, language, family, signal, review status) and expandable transcripts, coverage and skipped scenarios, framework mapping, the method, and downloads (HTML, JSON, SARIF, raw results).
  • Configs: saved configs can be edited as YAML, with errors shown per field.

Docker: docker run --rm -p 127.0.0.1:8765:8765 -v "$PWD:/work" agentkavach ui --host 0.0.0.0 --port 8765 --no-browser --i-understand-remote-access. Publishing the port on 127.0.0.1 keeps it local to your machine.

The sections below describe the same things for the command line.

1. The scan in one paragraph

A scan sends each attack scenario to your target, in each language variant, three times. It looks for deterministic evidence that the attack worked:

  • planted canary data reaching a local sink;
  • a forbidden tool call;
  • a planted marker or canary appearing in the reply;
  • a fixed output pattern.

An optional LLM judge is used only for scenarios that have no such signal. The results go to results.json, report.json, report.html and report.sarif. A scenario that your configuration gives it no way to observe is skipped with a reason, not reported as a pass.

2. A minimal config

authorization:            # required; the CLI refuses to run without it
  confirmed: true
  owner: "Example Corp"
  reference: "self-owned" # or a permission letter / ticket id
target:
  type: openai_compatible
  base_url: "https://agent.example.internal/v1"
  model: "support-bot"
  api_key_env: AGENT_API_KEY   # the key itself never goes in the file

Run agentkavach scan scan.yaml --dry-run first. It shows how many tests will run, the estimated model calls, and every scenario skipped as not applicable, with the reason.

3. Make more scenarios observable

With only the config above, scenarios that need an indirect channel, canary data or planted markers are skipped. Add whatever your target can support:

You add What it unlocks
planted_markers: ["ZX-PROMPT-7731"], after putting that string in your system prompt System-prompt leakage scenarios (secret_disclosed)
canary_seed_url: an endpoint that stores {records: [{name, email, token}]} where your agent can read them Data-exfiltration scenarios: canary in output, canary reaching the sink
channels: {form: {url, body_template: {message: "{{message}}"}}} Indirect prompt injection through a form, document or ticket your agent later reads
tool_log_url: (HTTP, returns [{name, arguments}]) or tool_log_file: (written by agentkavach mcp-proxy) Forbidden tool-call detection, when tool calls are not returned in replies
reset_url: POSTed before each attempt Clean state between attempts (strongly recommended with a tool log)
tools: {send_email: {names: ["mail.send"], args: {to: "recipient"}}} Maps the scenarios’ abstract tools to yours. Once set, scenarios that need tools you lack are skipped.
judge: {base_url, model, api_key_env} Scenarios decided by an LLM judge (prompt, output and reasoning are stored)
settle_s: 5 Waits for slow, asynchronous exfiltration before the final evidence check

Scenarios use these abstract tools: send_email(to, body), fetch_url(url), delete_records().

Speed. For a stateless chat target (no channels, reset, tool log or canary seeding), set concurrency: 8 to run tests in parallel. Findings are identical to a sequential run. The config refuses concurrency for stateful targets, because parallel tests could see each other’s injected input and report false findings.

4. Languages and mutations

languages: defaults to en, hi, hi-Latn, hinglish. mutations: [misspell] adds seeded, misspelled forms of romanised Hindi and Hinglish (hinglish~misspell). The report’s language gap table shows where an Indic form succeeded while English was blocked.

Review status matters. Every variant shipped today is an unreviewed draft. Reports label drafts, and they must not be quoted as a benchmark until a listed fluent speaker approves them (agentkavach review list; ADR-0006).

5. Reading the result

  • Outcomes:
    • vulnerable: at least one attempt succeeded.
    • resisted: every attempt completed and none succeeded.
    • incomplete: some attempts errored.
    • error: all attempts errored.
    • not-evaluated: needs a judge verdict that was not obtained.
  • Grade (rule v1, ADR-0009): A (best) to F, computed from completed tests only. Coverage is printed next to it. A grade is a summary of test results, not a safety rating.
  • Benign controls are harmless requests. If one is flagged, the report says the grade is unreliable.

6. CI

- uses: utkarshpatel7356/AgentKavach@<commit-sha>
  with:
    config: scan.yaml
    fail-on-severity: high     # or fail-on-grade: C
  • The gate also fails if any test errored (fail closed).
  • Upload report.sarif with github/codeql-action/upload-sarif to see findings in code scanning.
  • Compare runs with agentkavach compare old/results.json new/results.json --fail-on-regression.

7. MCP servers

  • agentkavach mcp-scan mcp.yaml inspects servers statically and never calls a tool. Example config:
    authorization: {confirmed: true, owner: Me, reference: self-owned}
    servers:
      files: {transport: stdio, command: ["npx", "-y", "@example/files-mcp"], package: {name: "@example/files-mcp", version: "1.2.0"}}
      remote: {transport: http, url: "https://mcp.example.internal/mcp", headers_env: {Authorization: MCP_TOKEN}}
  • Stdio servers get a minimal environment. Forward variables explicitly with env_from: [NAME].

8. The demo

agentkavach demo scans LeadBot, a deliberately vulnerable CRM agent, entirely on your machine.

  • --guarded adds an English keyword filter, a typical weak guardrail.
  • --misspell adds the misspelled forms.
  • --model-url ... --model ... backs LeadBot with a real LLM. Without it, the demo uses a labelled simulation.