Skip to content

fix: reject malformed and future webhook timestamps - #1723

Open
flcrom wants to merge 1 commit into
workos:mainfrom
flcrom:fix-webhook-timestamp-tolerance
Open

flcrom wants to merge 1 commit into
workos:mainfrom
flcrom:fix-webhook-timestamp-tolerance

Conversation

@flcrom

@flcrom flcrom commented Oct 10, 2026

Copy link
Copy Markdown

Fixes #1698.

verifyHeader only rejected timestamps that were too old, so a future-dated header passed. It now compares the absolute difference against the tolerance, and rejects a t= value that isn't a plain integer (before, parseInt returned NaN for junk and every comparison with it was false).

The WorkOS docs say the timestamp is milliseconds since the epoch (https://workos.com/docs/webhooks), which is what the check compares. Three spec fixtures built their timestamp as Date.now() * 1000, microseconds, so I changed them to Date.now() to match the docs.

Added tests for malformed values and for offsets just inside and just outside the tolerance. Ran the full suite on Node 22 and 24 locally.

@flcrom
flcrom requested review from a team as code owners October 10, 2026 05:01
@flcrom
flcrom requested a review from dandorman October 10, 2026 05:01
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical impact] The PR appears safe to merge.

Summary

verifyHeader now rejects malformed timestamps and timestamps outside the allowed window in either direction.

  • Webhook signatures reject bad timestamps and check both time directions.

Reviews (1) · Last reviewed commit: "fix: reject malformed and future webhook..." · Reviewed by Greptile

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

SignatureProvider.verifyHeader accepts future timestamps: the tolerance check is one-sided

1 participant