Signature Verification

Verify webhook signatures to ensure requests are authentic and haven't been tampered with.

Why Verify Signatures?

Webhook signatures protect your application from:

  • Spoofed requests: Attackers sending fake webhooks to your endpoint
  • Replay attacks: Reusing old webhook payloads
  • Tampering: Modified payloads in transit
Security Critical
Always verify webhook signatures in production. Failing to do so leaves your application vulnerable to accepting forged verification results.

Signature Headers

Each webhook request includes these headers:

HeaderDescription
x-owl-eyes-signatureHMAC-SHA256 signature of the payload
x-owl-eyes-timestampUnix timestamp when the request was sent

Verification Algorithm

The signature is computed as follows:

  1. Create the signed payload

    Concatenate the timestamp and raw request body with a dot separator:

    {timestamp}.{body}
  2. Compute HMAC-SHA256

    Hash the signed payload using your webhook signing secret.

  3. Compare signatures

    Compare the computed signature with the one in the header using a timing-safe comparison.

  4. Verify timestamp

    Ensure the timestamp is within an acceptable range (e.g., 5 minutes).

Node.js Implementation

node-verification.jsjavascript
Loading...

Python Implementation

python-verification.pypython
Loading...

Go Implementation

go-verification.gogo
Loading...

PHP Implementation

php-verification.phpphp
Loading...

Common Issues

Body Parsing Issue

Ensure you're using the raw request body, not a parsed JSON object. Body parsing middleware can modify the body before signature verification.

Encoding Mismatch

The body should be treated as UTF-8. Ensure your framework isn't modifying the encoding.

Clock Skew

If timestamp validation fails, check your server's clock. Use NTP to keep it synchronized.

Wrong Secret

Each webhook endpoint has its own secret. Make sure you're using the correct one for the endpoint.

Testing Signature Verification

test-signature.jsjavascript
Loading...