Skip to content

About

recoil — offline, LLM-free, pure-stdlib auditor for the A2A push-notification / webhook callback channel (PushNotificationConfig SSRF, DNS-rebinding, signed-JWT delivery auth, lifecycle amplification, injection); 34 rules / 8 families, severity score + CI gate

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Development Experiment 026 — recoil

An offline, LLM-free, dependency-free (pure-stdlib) auditor for the A2A push-notification / webhook callback channel.

recoil audits a captured A2A push-notification exchange — the PushNotificationConfig registrations a host agent made against a remote agent's tasks, plus the outbound webhook deliveries the remote agent fired at those URLs and the JWTs it presented — and grades it for SSRF, DNS-rebinding, transport, authentication, replay, injection and conformance defects. It ships a 34-rule catalog in 8 families, a severity-weighted score + letter grade, and a CI exit-code gate.


Thesis

The A2A (Agent2Agent) protocol lets a client register a webhook so a remote agent can push task-status updates back to it (PushNotificationConfig {url, token, authentication}). This one struct is the sharpest, least-audited attack surface in agent interop: the spec's own security section warns that a server must not blindly POST to a client-supplied URL, because a malicious client can aim the callback at 169.254.169.254 or an internal service and turn the server into an SSRF proxy / DDoS amplifier — and, in the other direction, a webhook receiver that fails to authenticate the caller will splice forged task updates straight into its planning LLM's context.

Experiment 025 (herald) opened the A2A layer by auditing the static Agent Card (discovery/identity). recoil is the runtime sequel: it audits the callback channel — the register → deliver → authenticate lifecycle — which no prior experiment touches (011–024 audit a single MCP channel, the HTTP transport, terminal rendering; 022 throughline does cross-channel taint but not the webhook mechanism). The official a2a-inspector explicitly skips push-notification and security checks, and every existing agent scanner is either a live debugger, an LLM guardrail, or a source-code linter. An offline, artifact-only, zero-dependency auditor over the webhook exchange did not exist.

The prototype is the smallest thing that proves the idea: a pure capture → findings function plus two byte-stable reference captures — a benign one that scores 100/A with zero findings, and a trojan that trips all eight families with seven CRITICALs and scores 0/F.


What it checks — the rule catalog (34 rules / 8 families)

Family What it catches Notable rules
SSRF webhook target aimed at an internal / metadata / obfuscated host SSRF01 cloud-metadata (CRITICAL), SSRF02 private/loopback/link-local (CRITICAL), SSRF04 decimal/hex/octal-packed IP, SSRF05 IPv4-mapped IPv6, SSRF06 userinfo authority confusion
REBIND register-vs-deliver DNS divergence (validated-once rebinding) REBIND01 registered-public/delivered-internal (CRITICAL), REBIND02 host straddling public+internal, REBIND03 resolution changed
XPORT webhook transport hygiene XPORT01 cleartext http (CRITICAL), XPORT02 dangerous scheme (CRITICAL), XPORT03 token smuggled into URL, XPORT05 non-https scheme
AUTH does the receiver authenticate the caller? AUTH01 no auth declared, AUTH02 scheme none, AUTH03 delivery presented none, AUTH04 weak token, AUTH05 token reused across sinks, AUTH07 inline credentials
JWT the spec's signed-JWT delivery auth JWT01 alg:none (CRITICAL), JWT02 symmetric HMAC, JWT03 missing iss/aud/iat/exp/jti/taskId, JWT04 expired-at-receipt, JWT05 audience not bound to webhook, JWT06 taskId mismatch (cross-task replay), JWT07 no jti, JWT08 attacker-controlled jku/x5u key source (CRITICAL)
LIFE config lifecycle & amplification abuse LIFE01 unsolicited/unknown-config delivery, LIFE02 late registration on a terminal task, LIFE03 replayed jti, LIFE04 webhook fan-out amplifier, LIFE05 duplicate body
INJ delivered payload injected back into the receiver's LLM context INJ01 instruction-override text, INJ02 zero-width/bidi/TAG concealment, INJ03 dangerous URL in payload, LAUNDER01 base64/hex/percent-encoded SSRF/injection
CONF PushNotificationConfig schema conformance CONF01 missing url, CONF02 unbound task, CONF03 unparseable url

Severity weights: CRITICAL 25 · HIGH 12 · MEDIUM 5 · LOW 2 · INFO 0. Score = max(0, 100 − Σ weights). Grades: A ≥ 90, B ≥ 80, C ≥ 70, D ≥ 60, else F. CI gate exit code: 0 pass · 1 grade below --min-grade (default B) · 2 any CRITICAL · 3 unreadable capture.


How to run

Requires Python 3.11+. No dependencies to install — it is pure standard library by design.

# audit a capture (human-readable)
python -m recoil captures/trojan.json

# machine-readable, for pipelines
python -m recoil captures/clean.json --json

# tighten the CI gate
python -m recoil captures/trojan.json --min-grade A

# optionally live-resolve webhook hostnames before auditing (the only
# networked path; off by default so audits stay deterministic/offline)
python -m recoil some-capture.json --resolve

Or via make:

make run      # audit the trojan capture
make test     # run the test suite
make demo     # audit both reference captures

Sample run (trojan capture)

========================================================================
recoil -- A2A push-notification / webhook callback auditor
capture: trojan: metadata SSRF, DNS rebinding, alg:none JWT, injection, replay, fan-out
========================================================================
score 0/100   grade F   findings: 29 (CRIT 7  HIGH 13  MED 7  LOW 2  INFO 0)
------------------------------------------------------------------------
!! [CRITICAL] JWT01      JWT     Delivery JWT uses alg=none
     where : delivery seq=30 task=t-noauth
     detail: an unsigned token is trivially forgeable -> notification spoofing
     evid  : none
!! [CRITICAL] REBIND01   REBIND  DNS rebinding: registered public, delivered internal
     where : delivery seq=31 host=webhook.trusted.com
     detail: registered ['1.1.1.1'] -> delivery hit ['10.0.0.5']
     evid  : ['10.0.0.5']
!! [CRITICAL] SSRF01     SSRF    Webhook targets cloud-metadata endpoint
     where : config seq=1 task=t-meta
     detail: cloud-metadata address 169.254.169.254 -- server becomes a confused-deputy credential thief
     evid  : http://169.254.169.254/latest/meta-data/iam/
...
------------------------------------------------------------------------
CI gate: FAIL (exit 2)
========================================================================

The clean capture, by contrast, prints score 100/100 grade A · No findings · CI gate: PASS (exit 0).


The capture format

A capture is a JSON object with configs (registrations) and deliveries (outbound webhook POSTs), plus optional tasks context. Fields mirror the A2A schema; resolvedIps records what a URL host resolved to (at registration and at delivery) so rebinding is decidable offline:

{
  "meta": { "description": "..." },
  "configs": [
    { "seq": 1, "taskId": "task-1", "configId": "cfg-1",
      "resolvedIps": ["93.184.216.34"],
      "pushNotificationConfig": {
        "url": "https://client.example.com/webhooks/abc",
        "token": "…",
        "authentication": { "schemes": ["Bearer"] } } }
  ],
  "deliveries": [
    { "seq": 2, "taskId": "task-1", "configId": "cfg-1",
      "url": "https://client.example.com/webhooks/abc",
      "receivedAt": 1754400000,
      "resolvedIps": ["93.184.216.34"],
      "authorization": "Bearer eyJ…",
      "event": { "kind": "status-update", "status": { "state": "completed" } } }
  ],
  "tasks": { "task-1": { "finalState": "completed" } }
}

captures/build_captures.py regenerates the two reference captures deterministically (and documents exactly how the embedded JWTs are formed).


Architecture

                      loader.py            analyzer.py            report.py
 capture.json  ─►  parse/normalize  ─►  PushCapture  ─►  [Finding]  ─►  score/grade/text/json
   (I/O)          (only I/O module)     (pure model)   (pure judge)     (pure render)
  • loader.py is the only module that touches the filesystem or network. load_capture normalizes JSON into the pure PushCapture model. resolve_hosts (opt-in, --resolve) is the single networked function and is never used by the analyzer or the tests.
  • model.py — frozen dataclasses (PushConfig, Delivery, Finding, Severity, PushCapture). No I/O, no clock.
  • netclass.py — host/IP SSRF classification built on stdlib ipaddress (metadata, loopback, private, link-local, ULA, IPv4-mapped, obfuscated numeric IPs) + a userinfo-aware URL parser.
  • jwt_lite.py — dependency-free JWT structural decoder (base64url header/payload; never verifies signatures — we hold no keys and the defects we flag are decidable from token shape alone).
  • textscan.py — Unicode concealment (zero-width/bidi/TAG/control), injection-intent matching, and encoded-launder decoding. inert() renders every byte of evidence safe to print.
  • analyzer.py — a pure, deterministic PushCapture → list[Finding] transform. No network, no filesystem, no clock, no randomness. Expiry checks are clockless: JWT exp/iat are compared against each delivery's recorded receivedAt.
  • report.py — scoring, grading, CI exit codes, and text/JSON rendering.

Design decision: observation vs. judgement (and why resolution is data)

The two approaches considered:

  1. Live-only prober — resolve DNS and fetch as we go. Rejected: it can't run in CI without a live network, it's non-deterministic (DNS flaps), and it can't re-audit a historical incident.
  2. Split observation from judgement (chosen, mirroring experiment 023 rampart): resolution results live in the capture as resolvedIps, and the analyzer is a pure function over that data. A live-captured session and a committed fixture therefore grade through the identical code path, every rule is unit-testable offline, and captured incidents can be committed and re-audited in CI. The (optional) live resolver is quarantined in loader.py.

Trade-offs: memory is trivial (a capture is small JSON held in RAM); CPU is linear in configs + deliveries with only local regex/parse work; maintenance cost is low because rules are small pure functions with one test each. The cost of the split is that offline audits are only as good as the resolvedIps the capture carries — which is the correct place to put that responsibility (the capturing proxy sees the real resolution; the auditor should not re-resolve and risk a different answer than what was actually contacted).

Self-defending output

Every finding's evidence is passed through textscan.inert() at construction time, so control bytes, ANSI escapes, and invisible/bidi Unicode from a hostile capture are escaped to \xNN / \uNNNN. Reading a recoil report can never drive the reader's terminal or hide part of the evidence — a property directly inspired by experiment 024 (escapement).


Assumptions & limitations

  • Structural, not cryptographic. recoil decodes JWTs to inspect algorithm, claims, and key-source; it does not verify signatures (no keys, and the flagged defects — alg:none, missing/expired claims, jku SSRF, audience mismatch — are decidable from shape). A structurally-valid but forged signature is out of scope by design.
  • Capture-provided resolution. SSRF-by-resolution and DNS-rebinding rules depend on the resolvedIps a capture records. If a capture omits them, recoil still flags literal-IP / metadata-hostname / cleartext / obfuscated-host and all JWT / auth / injection / lifecycle defects, but cannot see a hostname that resolves internal. --resolve can fill them in, at the cost of determinism.
  • Heuristic injection matching. INJ01 uses a deliberately narrow, high-signal phrase set (it flags behaviour, not the mere word "ignore"); a novel paraphrase can evade it. It is a linter, not a semantic guarantee.
  • The A2A push schema is still evolving (the draft v1.0 spec; a2a.proto is the normative source and a2a.json a generated artifact). recoil tolerates common shape variance (authentication as an object, a bare string, or absent; configId at the wrapper or inside the config) but a future rename could require a loader tweak — isolated to loader.py.
  • Single exchange. recoil audits one capture; it does not correlate across many agents or maintain longitudinal state.

Prior art (honest note)

Webhook-SSRF hardening, JOSE/JWT validators, and SSRF URL classifiers all exist independently, and the underlying attack classes are documented (the A2A spec's own SSRF/DDoS warning; Agent Card Poisoning, Keysight Mar 2026; the Plane webhook 169.254.169.254 advisory GHSA-fpx8-73gf-7x73; the DNS-rebind-at- delivery class). What did not exist is a single A2A-push-schema-aware, offline, LLM-free, dependency-free auditor that unifies webhook SSRF

  • register/deliver DNS-rebinding + transport hygiene + receiver authentication + the spec's signed-JWT delivery contract (alg/claims/key-source/replay) + lifecycle amplification + delivered-content injection over one captured push-notification exchange, with a severity score and a CI gate. The official a2a-inspector is a live debugger that explicitly does not cover push-notification or security checks. See RESEARCH.md for the signals.

License

MIT — see LICENSE.

About

recoil — offline, LLM-free, pure-stdlib auditor for the A2A push-notification / webhook callback channel (PushNotificationConfig SSRF, DNS-rebinding, signed-JWT delivery auth, lifecycle amplification, injection); 34 rules / 8 families, severity score + CI gate

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages