Skip to content

feat(webhooks): add timestamped HMAC verification#1660

Merged
Aaronontheweb merged 11 commits into
netclaw-dev:devfrom
Aaronontheweb:investigate/issue-1658
Jul 16, 2026
Merged

feat(webhooks): add timestamped HMAC verification#1660
Aaronontheweb merged 11 commits into
netclaw-dev:devfrom
Aaronontheweb:investigate/issue-1658

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add an explicit, opt-in HmacTimestamped verifier for Stripe-style t=...,v1=... signatures over timestamp.raw-body
  • enforce configurable replay tolerance, support multiple rotation signatures, and retain fixed-time signature comparison
  • expose the verifier through route configuration, CLI, and webhook tools with schema and operational guidance
  • harden route-store updates against concurrent writers and make daemon restart-drain tests deterministic with causal synchronization and virtual time

Backward compatibility

  • Hmac remains the default and its raw-body verification behavior is unchanged
  • HeaderSecret remains supported without migration
  • existing route files omit the new timestamp properties and round-trip without acquiring them
  • the new verifier must be selected explicitly; there is no auto-detection or security fallback
  • unrelated CLI and tool updates preserve existing verification settings

Validation

  • full solution build: 0 warnings, 0 errors
  • full test suite: 5,964 passed, 14 environment-dependent skips, 0 failed
  • restart-drain tests: 10 consecutive deterministic runs, 60/60 passed
  • targeted timestamped-webhook behavioral eval: 5/5 passed against Spark
  • OpenSpec strict validation passed
  • Slopwatch and copyright-header verification passed
  • final independent review found no P0-P3 issues

Documentation follow-ups

Closes #1658

@Aaronontheweb Aaronontheweb added webhooks Issues related to inbound netclaw webhooks config Configuration issues, netclaw doctor, schema validation. labels Jul 15, 2026
@Aaronontheweb
Aaronontheweb requested a review from Copilot July 15, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an explicit, opt-in HmacTimestamped webhook verifier (Stripe-style t=...,v1=...) with replay tolerance enforcement, exposes the new verifier across route config + CLI + tools + schemas + ops guidance, and improves determinism/cancellation semantics in daemon restart drain flows.

Changes:

  • Add WebhookVerifierKind.HmacTimestamped verification: structured header parsing, rotation signatures support, and timestamp replay-tolerance enforcement using TimeProvider.
  • Extend configuration + validation + JSON schemas + CLI/tool surfaces (including eval coverage) to support timestamped verification settings while preserving legacy route behavior.
  • Harden route persistence updates for concurrent writers (interprocess route-scoped lock) and make restart-drain tests deterministic via causal synchronization and virtual time.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Netclaw.Daemon/Webhooks/WebhookRequestVerifier.cs Adds timestamped-HMAC verification branch with tolerance enforcement.
src/Netclaw.Daemon/Webhooks/RegisteredWebhookRoute.cs Adds effective-default accessors for timestamped verification settings.
src/Netclaw.Daemon/Services/SessionDrainHelper.cs Splits cancellation tokens to distinguish deadline timeout vs caller cancellation; adds drain-ack log event.
src/Netclaw.Daemon/Services/DaemonRestartCoordinator.cs Uses virtual time for drain deadline CTS and passes separate cancellation tokens to drain helper.
src/Netclaw.Daemon/Program.cs Updates drain helper call site; registers verifier via DI.
src/Netclaw.Daemon.Tests/Webhooks/WebhookRouteCatalogTests.cs Adds tests ensuring unknown/future verifier kinds only invalidate the affected route.
src/Netclaw.Daemon.Tests/Webhooks/WebhookRequestVerifierTests.cs Adds unit coverage for timestamped-HMAC: defaults, rotation, custom fields, tolerance boundaries, malformed headers.
src/Netclaw.Daemon.Tests/Webhooks/WebhookEndpointRouteBuilderExtensionsTests.cs Adds endpoint-level tests for timestamped signature acceptance/rejection without dispatch on stale timestamps.
src/Netclaw.Daemon.Tests/Services/DaemonRestartCoordinatorTests.cs Refactors restart-drain tests to be deterministic using FakeTimeProvider and explicit ack coordination.
src/Netclaw.Configuration/WebhooksConfig.cs Adds optional timestamped verification fields and new enum value.
src/Netclaw.Configuration/WebhookRouteValidator.cs Adds enum validation, timestamped-specific validation, and CLI/tool kind parsing helper.
src/Netclaw.Configuration/WebhookRouteStore.cs Introduces route-scoped interprocess locking + atomic write strategy; adds Update API and cancellable Delete.
src/Netclaw.Configuration/Schemas/webhook-route.v1.schema.json Extends route schema for timestamped verification fields + conditional constraints.
src/Netclaw.Configuration/Schemas/netclaw-config.v1.schema.json Extends embedded config schema for timestamped verification fields + conditional constraints.
src/Netclaw.Configuration.Tests/WebhookRouteStoreTests.cs Adds coverage for legacy round-trip behavior, timestamped validation, schema parity, and concurrent Update serialization.
src/Netclaw.Cli/Webhooks/WebhooksCommand.cs Adds timestamped verifier support in list/show/set/validate output + arguments; uses route store Update for atomic updates.
src/Netclaw.Cli.Tests/Webhooks/WebhooksCommandTests.cs Adds CLI tests for timestamped persistence, validation failures, output shape, and schema evaluation.
src/Netclaw.Actors/Tools/SetWebhookTool.cs Extends set_webhook tool schema + persistence to support timestamped options and preserve omitted settings under store lock.
src/Netclaw.Actors/Tools/DeleteWebhookTool.cs Updates deletion to use cancellable store delete with timeout handling.
src/Netclaw.Actors.Tests/Tools/SetWebhookToolProvenanceTests.cs Adds tests for timestamped options persistence, rejection rules, and update-preserves-omitted-settings behavior.
openspec/specs/inbound-webhooks/spec.md Updates capability spec to include timestamped-HMAC verification and related requirements/scenarios.
openspec/changes/add-timestamped-webhook-hmac/tasks.md Adds OpenSpec task checklist for the change.
openspec/changes/add-timestamped-webhook-hmac/specs/inbound-webhooks/spec.md Adds delta spec describing modified/added requirements for timestamped-HMAC.
openspec/changes/add-timestamped-webhook-hmac/proposal.md Documents motivation, scope, compatibility, and impact for the change.
openspec/changes/add-timestamped-webhook-hmac/design.md Documents design decisions, constraints, and trade-offs.
openspec/changes/add-timestamped-webhook-hmac/.openspec.yaml Declares OpenSpec change metadata.
feeds/skills/.system/files/netclaw-operations/SKILL.md Bumps operations skill version.
feeds/skills/.system/files/netclaw-operations/references/webhooks.md Adds operator guidance for timestamped-HMAC selection and configuration.
evals/run-evals.sh Adds eval asserting set_webhook usage for Stripe timestamped verification.
evals/README.md Updates eval suite expectations to include timestamped webhook configuration.
evals/fixtures/config/netclaw.json Enables Webhooks.Enabled in eval fixture config.
docs/spec/configuration.md Documents timestamped verifier usage and exposes new route verification fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Netclaw.Daemon/Webhooks/WebhookRequestVerifier.cs
Comment thread docs/spec/configuration.md

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - going to test this out in the beta lane with a real webhook origin

if (!Enum.IsDefined(route.Verification.HmacAlgorithm))
errors.Add($"Verification.HmacAlgorithm value '{(int)route.Verification.HmacAlgorithm}' is not supported.");

if (route.Verification.Kind == WebhookVerifierKind.HmacTimestamped)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new feature we're adding here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration issues, netclaw doctor, schema validation. webhooks Issues related to inbound netclaw webhooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Stripe-style timestamped-HMAC webhook signature verifier (t=,v1= over {timestamp}.{body})

2 participants