Skip to content

Use constant-time comparison and a cached HMAC for webhook signature verification #2147

Description

@RUKAYAT-CODER

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

  • Measurable performance/efficiency improvement demonstrated with before/after numbers
  • No regression in existing functionality
  • Tests pass and code follows project standards
  • Change is documented

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions