Skip to content

[Bounty: $70] Reject future-dated and over-skewed timestamps in verifyWebhookWithReplay #404

Description

@jefferyikhidero

Context

verifyWebhookWithReplay in src/webhooks.ts only rejects a signed header when Date.now() - timestamp > toleranceMs; a header whose t= value lies in the future produces a negative age that always passes, and parseWebhookHeader accepts any integer it can parse. A far-future t= combined with a valid HMAC therefore verifies as true, and no allowance is made for clock skew between the sender and the verifier.

Proposed Change

Reject timestamps that fall outside the window [-toleranceMs, +toleranceMs] so small negative skew is tolerated but future-dated signatures are refused, and validate that toleranceMs is a positive finite number.

Acceptance Criteria

  • A header with t = Date.now() + 600_000 and a correctly signed payload returns false
  • Boundary tests cover timestamps at exactly +/-toleranceMs and +/-toleranceMs + 1
  • Existing valid-recent-signature and expired-signature cases in tests/webhook-verification.test.ts still pass

Suggested Label

bug

ETA: 24 hours

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions