Context
Webhook payloads travel over the internet and could be intercepted or modified in transit, leading to merchants acting on falsified data.
Current Limitation/Problem
Webhook payloads have basic signature verification but lack comprehensive tamper-proofing including payload body hashing, signed headers, and timestamp validation.
Expected Outcome
Tamper-proof webhook delivery with HMAC-SHA256 payload signatures, timestamp binding, and optional payload encryption. Merchants can verify authenticity without contacting the server.
Acceptance Criteria
- Sign webhook payload with HMAC-SHA256 using merchant-specific secret
- Include signature in header:
X-AgenticPay-Signature
- Include timestamp header for replay protection (<5min tolerance)
- Support multiple signature versions for key rotation
- Include signature in webhook body as
webhook.signature field
- Optional payload encryption with merchant public key
- Merchant verification guide and code examples in docs
- SDK method:
verifyWebhookSignature(payload, signature, secret)
- Automatic secret rotation (90-day expiration)
Technical Scope
backend/src/services/webhooks/signer.ts - payload signing
packages/sdk/src/webhooks/verifier.ts - signature verification
backend/src/services/webhooks/encryption.ts - optional payload encryption
- Prisma:
WebhookSecret model with rotation tracking
- Frontend: webhook secret management UI
- Edge cases: payload too large (streaming hash), key rotation period, clock skew
Context
Webhook payloads travel over the internet and could be intercepted or modified in transit, leading to merchants acting on falsified data.
Current Limitation/Problem
Webhook payloads have basic signature verification but lack comprehensive tamper-proofing including payload body hashing, signed headers, and timestamp validation.
Expected Outcome
Tamper-proof webhook delivery with HMAC-SHA256 payload signatures, timestamp binding, and optional payload encryption. Merchants can verify authenticity without contacting the server.
Acceptance Criteria
X-AgenticPay-Signaturewebhook.signaturefieldverifyWebhookSignature(payload, signature, secret)Technical Scope
backend/src/services/webhooks/signer.ts- payload signingpackages/sdk/src/webhooks/verifier.ts- signature verificationbackend/src/services/webhooks/encryption.ts- optional payload encryptionWebhookSecretmodel with rotation tracking