Skip to content

fix(webhooks): validate decoded payload shape in constructEvent - #1771

Open
shafiktanbir wants to merge 1 commit into
workos:mainfrom
shafiktanbir:fix/validate-webhook-event-payload
Open

shafiktanbir wants to merge 1 commit into
workos:mainfrom
shafiktanbir:fix/validate-webhook-event-payload

Conversation

@shafiktanbir

Copy link
Copy Markdown

Description

Fixes #1699.

Webhooks.constructEvent verified the HMAC signature and cast the parsed JSON directly to EventResponse, allowing signed null, primitives, arrays, or partial objects missing id, event, or object data to reach deserializeEvent and trigger raw TypeError failures or return incomplete event objects.

parseVerifiedPayload now validates that the verified payload is a non-null JSON object with string id, string event, and object data fields before deserialization, with unit tests in src/webhooks/webhooks.spec.ts.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@shafiktanbir
shafiktanbir requested review from a team as code owners November 22, 2026 19:00
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

constructEvent now checks the verified payload before passing it to deserializeEvent.

  • Webhook events are checked for their required fields before they are built.

No actionable issues found. Tests were not run.

Reviews (1) · Last reviewed commit: "fix(webhooks): validate decoded payload ..." · Reviewed by Greptile

@csrbarber
csrbarber requested a review from gjtorikian November 25, 2026 14:02
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.

constructEvent does not validate the payload shape after verifying the signature

1 participant