Repository navigation
feat(webhooks): make callback_url callable with the webhook secret - #1240
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks. The secret check is sound:
- it compares in constant time;
- it is scoped to the opportunity's own brand;
- an unknown id gets the same 401 as a wrong secret;
- only the status changes.
One change before merge:
The rate limit. publicLimiter allows 30 requests per 15 minutes per IP. n8n cloud, Zapier and Make send from IP pools shared by all their customers. One bulk send of 20 opportunities with an in_progress and a done callback each is already 40 calls. Anyone else on the same pool can also use up the bucket. Bot ingest hit the same problem, and botIngestKey keys by the secret's hash. Please key this limiter the same way, with a higher ceiling, and keep a small IP limiter that counts only failed (401) attempts. Update the line in webhooks.mdx too.
Smaller:
sentcan overwrite a callback. Both send routes setstatus: 'sent'after the receiver answers. A workflow that calls back before it responds (n8n's "respond when last node finishes") has itsin_progressordoneoverwritten. Only setsentif the status hasn't moved since the send began.- Docs: say that callbacks need a secret; it is optional in settings today.
- Tests: add a secret from another brand, a config without a secret, and an unknown id (all 401).
- Bad ids: a non-UUID
:idbecomes a 500 (Postgres 22P02). Check the shape first and return the same 401.
|
Maintainer follow-up addressed on the current branch.
Latest CI run #2391 passed all server, web and schema jobs. |
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, this works now. Keying the budget by the secret and keeping a separate limiter for failed attempts solves the shared-IP problem for valid callbacks. Tested on top of main with #1239, #1241, #1242 and #1131: server 1,897 and web 1,796 tests pass, and lint and Prettier are clean.
One thing for a follow-up, not a blocker: the failed-attempt limiter is per IP, so ten 401s from one Zapier or Make customer with a stale secret also block every other customer's callbacks from that egress IP for 15 minutes. Keying it by IP plus opportunity id would keep a bad secret from blocking anyone else.
Summary
POST /webhooks/content/:id/statusendpoint outside the authenticated/apiroutes.X-Webhook-Secretagainst the brand's active webhook secret using a constant-time comparison; reject missing or incorrect secrets.opportunity.sentpayloads to include the newcallback_urlandcallback_method: "POST".Related issue
Closes #912
Type of change
Validation
npm testfromserver/— 1,825 tests passednpm run lintfromserver/npm run format:checkfromserver/The server test, lint, and format commands passed locally. GitHub Actions CI will run after this PR is opened.