Skip to content

security(webhooks): delivery id is not signed, so a captured delivery replays under new ids #678

Closed

Description

@ajianaz

Found in the #594 security audit. Severity: medium. Status: confirmed (failing test).

Affected code

  • crates/tole-core/src/webhook.rs:116 verify: native scheme signs <timestamp>.<body>, GitHub scheme signs <body>; the returned id comes from X-Tole-Delivery / X-GitHub-Delivery, which neither signature covers.
  • crates/tole-cli/src/serve.rs handle_hook: idempotency is record_hook(name, &id, now) on that unsigned id; the events allowlist (hook_filter::event_allowed) uses the unsigned X-GitHub-Event header.

Problem

The module doc says "within that window the delivery id makes it run once" and, for GitHub, "replay protection is the delivery id alone". Since the id is attacker-chosen, a captured request replays with a fresh id: within 300 s for the native scheme, forever for the GitHub scheme (no timestamp). Each replay fires the route's cron job (LLM spend, and Write tools with allow_writes). tole serve speaks plain HTTP, so a capture only needs a position on the path, a proxy log, or a leaked delivery from the sender's UI.

Scenario

A GitHub issues.opened delivery to a route with allow_writes = true is captured once. Months later the attacker re-posts the same body and signature with a new X-GitHub-Delivery (and any X-GitHub-Event the allowlist accepts), once per rate-limit window: each runs the agent job again.

Reproduction

Scratch test crates/tole-core/tests/audit_594.rs::a_captured_delivery_cannot_be_replayed_under_a_new_id: the same signed body verifies as Ok("orig-1") and Ok("replay-2") (native, +200 s) and as Ok("g-1") and Ok("g-2") (GitHub, +365 days).

Suggested fix

  • Native: sign <timestamp>.<delivery>.<body> (version the scheme, e.g. v2), reject a delivery header that is not covered.
  • GitHub: key idempotency on sha256(signature || body) (signed material), not the header id; keep it at least HOOK_RETENTION_SECS, and document that GitHub deliveries have no freshness bound (recommend a TLS front and the native scheme for anything with allow_writes).
  • Treat the event name as untrusted: for GitHub, derive it from the signed payload where possible, or document that events is not a security boundary.

Activity

  1. added
    bug
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions