Overview
HookStack signs every webhook request to ensure the authenticity and integrity of the payload. This guide explains how to verify these signatures in your webhook handlers.Understanding the Signature
Each webhook request from HookStack includes several security-related headers:- The timestamp from the
X-HookStack-Timestampheader - The version from the
X-HookStack-Versionheader - The complete JSON-stringified payload
Verifying the Signature
Here’s how to verify the signature in your webhook handler:verifyWebhookSignature.ts
Using timing-safe comparison when verifying signatures, or checking the timestamp against the
current time helps prevent timing attacks.
Best Practices
Verify Every Request
Verify Every Request
Always verify the signature before processing any webhook payload
Check Timestamp
Check Timestamp
Verify the timestamp is recent (within 5 minutes) to prevent replay attacks
Use Environment Variables
Use Environment Variables
Store your signing secret in environment variables, never in code
Handle Errors Gracefully
Handle Errors Gracefully
Return appropriate HTTP status codes for verification failures;
this allows HookStack to retry the request.
The signing secret is provided in your HookStack dashboard under each Destination.It is required for HTTP-type Destinations only.
Testing Verification
HookStack provides test endpoints and signing secrets in the dashboard to help you verify your implementation:- Use the test webhook feature in the dashboard
- Check the test logs to see detailed request/response information
- Verify your error handling by sending invalid signatures