Background
BackEnd/src/modules/webhooks/webhooks.service.ts re-derives the HMAC and compares signatures with a plain string comparison on every webhook, adding avoidable per-request CPU and a timing side-channel on the verification hot path.
Implementation Plan
- Replace the string equality check with
crypto.timingSafeEqual over equal-length buffers in webhooks.service.ts
- Reuse a cached/precomputed HMAC key or instance instead of re-deriving the secret per request
- Add benchmarks/metrics capturing before/after impact
- Add regression tests where applicable
- Document the change
Acceptance Criteria
Background
BackEnd/src/modules/webhooks/webhooks.service.tsre-derives the HMAC and compares signatures with a plain string comparison on every webhook, adding avoidable per-request CPU and a timing side-channel on the verification hot path.Implementation Plan
crypto.timingSafeEqualover equal-length buffers inwebhooks.service.tsAcceptance Criteria