Skip to content

Enforce HMAC signature verification on inbound webhook routes in webhook.routes.ts #318

@greatest0fallt1me

Description

@greatest0fallt1me

Description

src/webhooks/webhook.signature.ts provides signing utilities, but inbound webhook routes must verify signatures and reject replays. This backend task adds signature-verification middleware to src/webhooks/webhook.routes.ts, including timestamp tolerance and a timing-safe comparison to prevent forged callbacks.

Requirements and Context

  • Verify the HMAC signature header against the raw request body.
  • Reject requests outside a configurable timestamp tolerance window (replay protection).
  • Use timing-safe comparison and return 401 on mismatch.
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/webhook-signature-verification
  2. Implement changes
    • src/webhooks/webhook.routes.ts — add verify middleware
    • src/webhooks/webhook.signature.ts — add verify helper
    • Preserve raw body for verification
  3. Test and commit
    • npm test -- src/webhooks/webhook.signature.test.ts src/webhooks/webhook.auth.test.ts
    • Cover edge cases
    • Include test output and notes in the PR

Example commit message

feat: verify HMAC signatures on inbound webhooks

Acceptance Criteria

  • Invalid or missing signatures are rejected with 401
  • Stale timestamps outside tolerance are rejected
  • Comparison is timing-safe

Guidelines

  • Minimum 90% test coverage with Jest
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programapiAPI endpoint/contract workbackendBackend service worksecuritySecurity hardening
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions