Skip to content

fix: verify Circle webhook signature against raw request body - #34

Open
mertcano wants to merge 1 commit into
circlefin:masterfrom
mertcano:mertcano-patch-1
Open

fix: verify Circle webhook signature against raw request body#34
mertcano wants to merge 1 commit into
circlefin:masterfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Similar to the recent fix in arc-p2p-payments, this prevents signature validation failures caused by re-serializing the JSON payload.

The webhook handler currently parses the request body and runs JSON.stringify() before verifying the signature. Since the re-serialized string is not guaranteed to be byte-for-byte identical to the original payload, valid webhooks can randomly get rejected.

This updates the handler to use req.text() for the cryptographic check and only parses the JSON after the signature is proven valid.

Similar to the recent fix in arc-p2p-payments, this prevents signature validation failures caused by re-serializing the JSON payload.

The webhook handler currently parses the request body and runs `JSON.stringify()` before verifying the signature. Since the re-serialized string is not guaranteed to be byte-for-byte identical to the original payload, valid webhooks can randomly get rejected.

This updates the handler to use `req.text()` for the cryptographic check and only parses the JSON after the signature is proven valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant