Check Content Encoding Before Defining SMS Webhook Signature Input

Published: · Updated:
Share

Signature input must follow the provider’s protocol when an SMS-related webhook uses content encoding. A no SIM mobile SMS number does not determine which representation is authenticated. Encoded bytes, decoded content and a reserialised JSON object can differ, so the receiving chain needs an explicit agreement.

Confirm what the endpoint supports

Read the meaning of Content-Encoding and whether that endpoint accepts the stated coding. MDN describes the header as identifying an encoding applied to content. It should not be confused with the media type or character set.

If a signature procedure says raw body, determine which stage that means in the actual contract. Stripe’s documentation provides a specific raw-body requirement for its mechanism. It does not define another provider’s algorithm or compressed-input processing order.

Unsupported representation needs a documented response, not a guessed decoding routine. Making one request pass by removing checks can create a receiver that no longer follows the expected protocol.

Trace content through the verification chain

Trace the whole receiving path

A proxy, server and framework may each read, decode or parse content. Identify which component performs which operation and compare the relevant stages with controlled input. Do not parse JSON and serialize it again while assuming whitespace, ordering and representation must remain identical.

Headers used to describe internal processing should come through a trusted arrangement. An arbitrary external assertion should not decide that verification has already occurred. After authentication, still validate event structure, resource relationships and business authority.

Keep content handling separate from signature result reporting. An application can decode successfully while still receiving an invalid or unauthorised event. A single success flag hides the stage needed for investigation.

Bound decoding and downstream work

Set appropriate input, expanded-size and time limits for supported representations, with explicit failure outcomes. Do not remove all resource controls to make a signature fixture easier to accept.

Diagnostic records can start with coding, length category and failure stage. Private bodies and reusable authentication material should not enter ordinary logs. Compare harmless data in a controlled environment instead of uploading customer requests to a public tool.

Check response diagnostics without changing the incoming data path. A debugging middleware can consume or transform a body before the handler reads it. Use the framework’s supported capture method and a controlled fixture to confirm what remains available. Avoid adding an ad hoc second parser that makes the test pass while introducing different production behaviour or unnecessary copies of private payloads.

Decoded content and reserialized JSON can differ

Verify both accepted and unsupported paths

Following the actual protocol, test a supported representation, changed content, an incorrect declaration and an unsupported coding. Inspect authentication and rejection behaviour through the deployed proxy and framework path.

Repeat the relevant fixture after middleware or proxy upgrades that could change body handling. A locally correct verification helper cannot establish that a different deployed component supplies the same input.

Retain the protocol version, read location and processing order in the maintenance note. That gives another operator a way to reproduce the boundary without retaining live codes. Close when the components agree on the intended contract and limits, not merely when a specially prepared request happens to pass once.

References: MDN: Content-Encoding; Stripe: webhook raw-body verification.

Need help?

Click here and start chatting with us!