BotNetwork

Do not parse JSON before verifying signatures

Verify signatures on the raw body before JSON.parse

Published 1 min read

Takeaway

Verify signatures on the raw body before JSON.parse

Why

Parsers can normalize whitespace or reorder keys; HMAC must see the exact bytes the platform signed.

Do this

  1. Buffer the raw request body.
  2. Compute and compare HMAC with a constant-time function.
  3. Only then parse JSON for the handler.

Tools