{
  "schema_version": "1.3.0",
  "slug": "across-what-timestamp-replay-and-idempotent-deduplication-gates-must-an-instance-verify-and-dispatch-webhooks-to-prevent-replay-attacks-and-duplicate-side-effects",
  "title": "Across what timestamp-replay and idempotent-deduplication gates must an instance verify and dispatch webhooks to prevent replay attacks and duplicate side effects?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** An AI instance, autonomous coding agent, or backend service implements inbound webhook verification endpoints, asynchronous callback receivers, or outbound webhook delivery workers. * **Does not apply when:** Serving syn",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/across-what-timestamp-replay-and-idempotent-deduplication-gates-must-an-instance-verify-and-dispatch-webhooks-to-prevent-replay-attacks-and-duplicate-side-effects.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/across-what-timestamp-replay-and-idempotent-deduplication-gates-must-an-instance-verify-and-dispatch-webhooks-to-prevent-replay-attacks-and-duplicate-side-effects.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/across-what-timestamp-replay-and-idempotent-deduplication-gates-must-an-instance-verify-and-dispatch-webhooks-to-prevent-replay-attacks-and-duplicate-side-effects.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 3084,
    "python_slice_tokens": 656,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Autonomous systems constantly integrate across organizational trust boundaries using HTTP webhooks—both receiving asynchronous event notifications from external providers and dispatching outbound state-change callbacks to customer-configured URLs. A foundational security and state-consistency failure occurs when an instance verifies an inbound webhook **sole...",
    "what_was_observed": "In payment webhook handlers, CI/CD GitHub hook receivers, and outbound customer notification dispatchers, instances operating without explicit replay-window and deduplication gates exhibit four primary failure modes: 1. **Unbounded Signature Replay (Body-Only HMAC):** An instance computes `hmac.new(secret, raw_body, sha256)` without including the `X-Webhook-Timestamp` header inside the HMAC signing input or checking ...",
    "condition_of_validity": "* **Applies when:** An AI instance, autonomous coding agent, or backend service implements inbound webhook verification endpoints, asynchronous callback receivers, or outbound webhook delivery workers. * **Does not apply when:** Serving synchronous, read-only `GET` queries that perform no state mutation and require no cryptographic webhook signature or idemp...",
    "decision_boundary": "1. **Does your webhook handler parse JSON first (`request.json()`) or read raw bytes (`request.body()`) to check the signature?** Always check the HMAC against the exact raw bytes received over the wire—never re-serialize a dictionary back to JSON to check a signature. 2. **Does your signature check include the delivery timestamp and reject requests older th...",
    "operational_effect": "1. **Timestamp-Bound Raw-Byte Verification:** Across all generated webhook receivers and signers, the instance verifies HMAC digests in constant time over `f\"{timestamp}.\".encode(\"ascii\") + raw_body` and enforces a strict $\\pm 300\\text{-second}$ replay window. 2. **Atomic `event_id` Deduplication:** Incoming webhook handlers claim the provider's unique event..."
  },
  "matched_failure_symptoms": [
    "DUPLICATE_MUTATION_OR_BILLING"
  ],
  "composition_edges": {
    "primary_domain": "asynchronous_quiescence_and_background_jobs",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/across-what-bounded-queue-admission-control-and-load-shedding-gates-must-an-instance-manage-concurrency-to-prevent-unbounded-memory-growth-and-tail-latency-collapse.md",
      "https://corpusfetch.com/c/across-what-deadline-propagation-and-cancellation-cascade-gates-must-an-instance-govern-grpc-and-http2-calls-to-prevent-zombie-worker-exhaustion-and-wasted-compute.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/before-what-pre-flight-and-dry-run-gates-must-an-instance-stage-bulk-or-irreversible-mutations-to-prevent-unrecoverable-blast-radius-cascade.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/across-what-readiness-unregistration-and-in-flight-drain-gates-must-an-instance-sequence-sigterm-shutdown-to-prevent-dropped-requests-and-truncated-writes.md",
      "https://corpusfetch.com/c/against-what-ordering-invariants-must-an-instance-reconstruct-state-transitions-when-reasoning-across-asynchronous-events.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "0f259372431c2efeb92bba7ae45b3b0863e4f58e588461a37b2636159109f302",
    "verified_classes": [
      "WebhookSecurityError",
      "VerifiedWebhookEvent",
      "ReplaySafeWebhookGuard"
    ],
    "verified_functions": [
      "__init__",
      "_init_dedup_table",
      "sign_outbound_webhook",
      "verify_and_claim_inbound"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "ValueError",
      "WebhookSecurityError"
    ],
    "sample_fail_closed_invariants": [
      "active_kid must exist in keyring",
      "Webhook payload missing or exceeds byte limit",
      "Webhook HMAC signature verification failed",
      "Webhook event 'id' must not be empty"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "hmac",
      "json",
      "sqlite3",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
