Skip to main content

Verifying Webhook Signatures

Every webhook from KnoxCall includes an HMAC-SHA256 signature. Verifying this signature ensures the webhook:
  1. Came from KnoxCall (not an attacker)
  2. Wasn’t modified in transit

How Signatures Work

When KnoxCall sends a webhook:
  1. Takes the JSON payload
  2. Signs it with your webhook’s secret key using HMAC-SHA256
  3. Includes the signature in the X-Webhook-Signature header
Your endpoint should:
  1. Get the signature from the header
  2. Compute the expected signature using the same secret
  3. Compare them (timing-safe comparison)
  4. Reject if they don’t match

Implementation Examples

Node.js (Express)

Python (Flask)

PHP

Go

Ruby (Sinatra)

Getting Your Webhook Secret

View Secret

  1. Click Automation in the sidebar, then select Webhooks
  2. Click on your webhook
  3. Click Reveal Secret
  4. Copy the secret
The secret looks like: a1b2c3d4e5f6... (64 hex characters)

Regenerate Secret

If your secret is compromised:
  1. Click Regenerate Secret
  2. Copy the new secret immediately
  3. Update your endpoint with the new secret
Regenerating invalidates the old secret immediately. Update your endpoint before regenerating, or webhooks will fail validation.

Common Mistakes

1. Parsing JSON Before Verification

Wrong:
Right:

2. Wrong Secret

Symptoms:
  • All signatures fail
  • No intermittent issues
Fix:
  • Copy secret directly from KnoxCall
  • Ensure no extra whitespace
  • Check environment variable is set

3. Non-Timing-Safe Comparison

Wrong:
Right:

4. Encoding Issues

Symptoms:
  • Signatures fail for certain payloads
  • Works for simple data, fails for special characters
Fix:
  • Use raw bytes, not decoded strings
  • Ensure UTF-8 encoding throughout

Security Best Practices

1. Always Verify Signatures

Never process webhooks without signature verification:

2. Store Secrets Securely

  • Use environment variables (not hardcoded)
  • Rotate secrets periodically
  • Use secrets management services in production

3. Reject Missing Signatures

4. Log Verification Failures

Monitor for repeated failures - could indicate an attack:

5. Use HTTPS Only

Signatures protect against tampering, but HTTPS protects against eavesdropping:
  • Always use HTTPS endpoints
  • Reject HTTP in production

Debugging Signature Issues

Step 1: Log Both Signatures

Step 2: Check Payload

Step 3: Verify Secret

Step 4: Test with Known Values

Use the KnoxCall test feature and compare:
  • Test payload vs what you receive
  • Expected signature vs what you compute

Next Steps

Testing Webhooks

Test your signature verification

Webhook Logs

Debug webhook issues

Creating Webhooks

Configure webhook settings

Webhooks Overview

Learn about webhooks

Statistics

  • Level: intermediate
  • Time: 8 minutes

Tags

webhooks, security, signatures, hmac, verification