Webhook Security
When Fileloom sends webhooks to your endpoint, you should verify the signature to ensure the request is authentic and hasn’t been tampered with.How Webhook Signing Works
Every webhook request includes a signature in theX-Fileloom-Signature header. This signature is created using:
- Your webhook secret (generated when you create the webhook)
- The raw request body
- HMAC-SHA256 algorithm
1
Fileloom Creates Payload
When an event occurs (e.g., PDF generated), Fileloom creates a JSON payload with the event data.
2
Fileloom Signs the Payload
Using your webhook secret, Fileloom computes an HMAC-SHA256 signature of the payload.
3
Your Server Receives the Request
The webhook is sent to your endpoint with the signature in the
X-Fileloom-Signature header.4
Your Server Verifies the Signature
Using the same secret, your server computes the expected signature and compares it.
5
Process if Valid
If signatures match, the request is authentic. Process the event data.
Webhook Headers
Each webhook request includes these headers:| Header | Description |
|---|---|
X-Fileloom-Signature | HMAC-SHA256 signature |
X-Fileloom-Timestamp | Unix timestamp when sent |
X-Fileloom-Event | Event type (e.g., pdf.generated) |
X-Fileloom-Delivery-Id | Unique delivery ID |
Verifying Signatures
Step 1: Get the Signature
Extract the signature from theX-Fileloom-Signature header:
Step 2: Compute Expected Signature
Using your webhook secret, compute the HMAC-SHA256 of the raw request body.Step 3: Compare Signatures
Use a timing-safe comparison to check if the signatures match.Code Examples
Preventing Replay Attacks
Use theX-Fileloom-Timestamp header to prevent replay attacks:
Webhook Secret Rotation
If your webhook secret is compromised:1
Generate New Secret
In your dashboard, go to the webhook settings and regenerate the secret.
2
Update Your Server
Deploy the new secret to your webhook handler.
3
Test the Webhook
Use the “Send Test” button to verify it works.
Troubleshooting
Signature Verification Fails
Signature Verification Fails
Common causes:
- Wrong secret - Ensure you’re using the correct webhook secret
- Payload modification - Don’t parse or modify the body before verifying
- Encoding issues - Use raw bytes, not decoded JSON
- Extra whitespace - Some frameworks add whitespace
Missing Signature Header
Missing Signature Header
Check that:
- Your endpoint is receiving POST requests
- The
X-Fileloom-Signatureheader isn’t being stripped by a proxy - You’re reading the correct header name (case-insensitive)
Timing-Safe Comparison
Timing-Safe Comparison
Always use timing-safe comparison functions:
- Node.js:
crypto.timingSafeEqual() - Python:
hmac.compare_digest() - PHP:
hash_equals() - Go:
hmac.Equal() - Ruby:
Rack::Utils.secure_compare()
===) is vulnerable to timing attacks.Security Checklist
- Verify signature on every webhook request
- Use timing-safe comparison
- Check timestamp to prevent replay attacks
- Store webhook secret in environment variables
- Use HTTPS for your webhook endpoint
- Return 200 quickly, process async if needed
- Log failed verification attempts