Skip to content

Sign the received bytes; never re-serialise before signing

Accepted.

2026-05-26 (the router’s signer and the SDK verifier; the rule is recorded in the wire contract).

Every delivery to a subscriber can carry an HMAC-SHA256 signature so the receiver can prove the platform sent it and that it was not changed. A signature is over bytes. JSON has no canonical encoding: key order, whitespace, escaping of <, > and &, number formatting and Unicode escapes differ between libraries. If a sender signs a structure it then serialises, or a receiver parses the body and re-encodes it to verify, the two sides can disagree on a body that is semantically identical. The failures are intermittent and depend on library versions, which makes them hard to diagnose.

There are several receivers: the platform’s own SDKs in several languages, framework receivers and customer code.

  • The signature is HMAC-SHA256(secret, timestamp + body), sent as lowercase hex in X-FLOWCATALYST-SIGNATURE, with the timestamp in X-FLOWCATALYST-TIMESTAMP (ISO 8601 UTC with exactly three fractional digits).
  • The sender signs the exact bytes it puts on the wire. For a dispatch-processing delivery the body is signed alone: other headers, such as the client header, are not covered. A dataOnly delivery signs the job’s raw payload byte for byte.
  • The receiver verifies the raw bytes it received, before any parsing. SDK verifiers take the body as bytes, and their documentation says so.
  • The one place a serialised structure is signed is the router’s mediation payload, {"messageId":"<id>"}. It is a single-field object, built so its bytes equal what the standard encoder would produce, including the escaping case, so there is no serialiser ambiguity.
  • Other signing in the platform is HMAC over plain strings (the dispatch auth token signs the raw job id) or not HMAC at all (JWT, password hashing, encryption). None signs serialised JSON.
  • The signer must byte-match the receivers, and a fixed test vector is meant to pin the expected signature on every side, so that a change moves all of them in lockstep.
  • A delivery that has no usable credentials goes out unsigned with a recorded reason, never signed by a different account.

Good:

  • The choice of JSON library cannot affect verification.
  • Any language can implement a verifier with an HMAC primitive and a body buffer.
  • A tampered body fails regardless of how it parses.

Bad:

  • Receivers must capture the raw body before a framework parses it. Middleware that parses first breaks verification.
  • A proxy that rewrites the body invalidates the signature.
  • The signature covers the body and timestamp only, so headers need their own protection if they matter.
Alternative Why not
Sign a canonical JSON form Needs every side to implement the same canonicalisation.
Sign a parsed structure The same data can encode differently per library.
Sign headers and body together Intermediaries commonly change headers.