Skip to content

constructEvent does not validate the payload shape after verifying the signature #1699

Description

@ccclapon

What we found

Webhooks.constructEvent verifies the signature, then parseVerifiedPayload casts the body with as unknown as EventResponse and hands it to deserializeEvent. Nothing checks the shape between the two steps.

Effect

The signature proves the origin of the payload, not its shape. A field that changes type, or a field that is absent, becomes a runtime error deep inside application code, and the error names neither the webhook nor the field. Consumers who want a safe boundary re-implement per-event guards that duplicate knowledge the SDK already holds in its interfaces and serializers.

Request

Validate the deserialized event against its declared shape and throw a named error that states the event type and the failing field. A schema library is not required; a small guard per event type is enough, and the generated interfaces already describe the expected shape.

Related

#1319 described the confusion between the camelCase Event type and the snake_case wire payload. A validation step at the boundary makes that boundary explicit.

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