Inspiration

Indian fintech teams are giving AI support agents real tools: customer KYC, the ledger, a refund button. One cleverly worded message, or an instruction hidden in a dispute note, can make that agent read out another customer's Aadhaar or refund money nobody approved. Red-team reports today are one-off PDFs, and nobody re-runs the Hinglish or base64 version of the attack after the patch. We wanted hardening to be a loop between two agents, where nothing counts as fixed until the attacker fails again.

What it does

Kavach puts a Red agent and a Blue agent on opposite sides of an AI support assistant.

The target is PaisaPal, a sample UPI-wallet support agent with five tools on a real sqlite3 database of synthetic customers (IDs shaped like Aadhaar, PAN and UPI handles; all sample data). Red signs in as an ordinary customer and proves six attack families mapped to the OWASP LLM Top 10: direct prompt injection, instructions hidden in stored dispute notes, cross-account KYC reads, uncapped refunds, SQL injection and PII in replies. Each attack has evasion variants (Hinglish, base64, a fake debug ticket, UNION, self-service paths). Evidence oracles check hard proof: a leaked credential, another customer's PII, a refund over policy, rows from other accounts.

Red sends each FINDING to Blue. Blue triages it with Finch's code-security-audit and pii-redactor skills, confirms or rejects every static hit, deploys input, tool, output and code-level guards, and asks Red to RETEST. Any bypass makes Blue escalate. In the recorded engagement, Blue's first prompt-injection patch stopped the plain and Hinglish attacks, but the base64 and debug-ticket variants still leaked the key; Blue escalated and round 2 blocked all four.

One engagement: attacks landing 15/15 before Blue, 0/15 after; 6/6 benign requests still served; 6/6 findings verified by retest; Finch's re-audit of the SQL fix takes confirmed injections from 1 to 0. These numbers are produced by the engine on every run, in your browser.

All 48 agent-to-agent messages are typed envelopes (kavach.a2a/0.1: HELLO, SCOPE, FINDING, TRIAGE, PATCH, RETEST, RESULT, VERIFIED, UTILITY, REPORT) in a SHA-256 hash chain. The console re-verifies the chain with WebCrypto and refuses a tampered record. You can also attack PaisaPal yourself in the sandbox with defenses on or off, and export a Kavach report as Markdown or PDF.

How we built it

  • Engine: stdlib-only Python (Red, Blue, guards, protocol, PaisaPal on sqlite3). The same code runs from the CLI (python -m kavach run) and in the browser through Pyodide in a Web Worker, so the live site needs no backend and no keys.
  • A2A protocol: canonical-JSON envelopes, each frozen at send time and chained by SHA-256; verified in Python and again in JavaScript.
  • Web: React + TypeScript + Vite landing page with a live Red/Blue arena, heatmap and report, plus an operator console (overview, engagements with a live timeline, findings with a retest matrix, defenses, sandbox, integrations, protocol spec). Deployed on GitHub Pages.
  • Finch (running): Blue vendors two Finch skills (FinchTech-AI, MIT) and calls their run() in-process about 30 times per engagement: static audit during triage, re-audit of Blue's SQL fix, measuring PII in leaked evidence, and as the core of Blue's output PII guard (Kavach adds Aadhaar, PAN and UPI detectors).
  • BAND (running live): Red and Blue are two real BAND agents. Blue opens a room and adds Red and the owner; every signed envelope is posted by its sender with an @mention of the other, so the hash chain also lives in BAND. Live run on 19 Nov 2026: room 7ff43cce-3629-492f-8a0d-aea4d893f640, 48 of 48 envelopes posted. Band's firewall blocks one message that contains a live SQL-injection string, so the adapter re-sends it base64-encoded with its sha256. Evidence is in docs/evidence/ in the repo.
  • Lyzr (adapter written, not connected yet): LyzrReasoner writes Blue's triage rationale through Lyzr's inference API (templated fallback, so defenses never depend on an LLM); LyzrTarget swaps PaisaPal for an LLM agent on Lyzr so Red's same oracles test a real model (--lyzr).
  • AdaL (adapter written, not connected yet): python -m kavach adal-pr engagement.json runs AdaL headless to draft the remediation pull request from a signed engagement record.
  • Agent37 (recipe): deploy/Dockerfile + deploy/agent37.md for a nightly always-on re-attack sandbox.

Challenges we ran into

  • One engine in two runtimes. The same Python had to run in CPython and in Pyodide inside a Web Worker, streaming envelopes into React as they were produced. A generator-based engagement loop and a stdlib-only engine (sqlite3 included) solved it.
  • Cross-language hash verification. Python and JavaScript serialise floats differently (9.0 vs 9), so browser verification failed. We moved to a canonical-JSON rule with no floats in the protocol and froze each body at send time; a mutated dict had broken the chain at message 5.
  • Honest static analysis. Finch's heuristics flagged DES inside ORDER BY … DESC and arithmetic + as SQL concatenation, which made the fix look like 2 → 2. Blue now assesses each hit against the code and the report separates confirmed findings, false positives and static-only hygiene issues.
  • Retests that mean something. A single replay hides bypasses, so every attack carries evasion variants, Blue escalates only when a variant still lands, and a utility suite proves fixes didn't break benign requests.

Accomplishments that we're proud of

  • A fix is never marked closed on Blue's say-so: it is closed only after Red's retest, evasion variants included.
  • A real escalation, driven by a real bypass, is visible in the record.
  • The whole engine runs in a browser tab with no backend, and every A2A message is independently verifiable.

What we learned

Agent-to-agent systems become trustworthy when the messages are typed, signed and replayable, and when one agent's claim has to be proven by the other. Utility checks matter as much as security checks: a guard that blocks real customers is a failed fix.

What's next for Kavach

Point Red at live LLM agents through Lyzr, mirror every engagement into a BAND room (done, live), run nightly on Agent37, and let AdaL open the fix pull request, so hardening becomes a continuous loop for teams shipping agents at UPI wallets, lenders and insurers. Kavach fits TheAdaply's work on infrastructure that makes AI agents safe to ship.

Built With

Share this project:

Updates

Submission history