flashman
← All guides

Signed URL canonicalization and verification guide

Build and debug signed URLs with deterministic paths, query ordering, percent-encoding, duplicate parameters, expiry checks, and reusable test vectors.

2026-08-28 · 8 min read

  • url
  • security
  • signatures

Signed URLs grant time-limited access by authenticating selected request components with a message authentication code or digital signature. Security depends on signer and verifier constructing exactly the same byte sequence from the request.

A URL parser is not a canonicalization specification. Libraries can differ on percent escapes, Unicode, plus signs, path segments, empty values, and duplicate query keys while still producing URLs that look equivalent in a browser.

Specify the canonical request

Write down every signed component and its order: HTTP method when relevant, normalized path, canonical query, selected headers, body digest, credential scope, and expiry. Define separators and newline behavior so independent implementations produce identical bytes.

  • Choose whether an empty path becomes slash.
  • Define dot-segment and repeated-slash handling.
  • Sort encoded names and values according to the protocol.
  • State whether the signature parameter itself is excluded.

Encode components exactly once

Percent-encode path segments and query names or values using the specification's character set. Do not encode a whole assembled URL, and do not decode then re-encode an incoming request unless the protocol explicitly defines that transformation.

Form encoding commonly turns spaces into plus signs, while URI percent-encoding uses %20. A literal plus sign therefore needs deliberate treatment. Normalize Unicode only if the signing protocol requires one form; otherwise preserve the defined input bytes.

Preserve duplicate and empty parameters

A map data structure may discard repeated query names or reorder entries. If the protocol permits duplicates, parse into an ordered multivalue representation and apply the documented sort rule to encoded names and encoded values.

  • Test key=, key, and an absent key separately.
  • Include repeated names with different and identical values.
  • Reject malformed percent escapes consistently.
  • Avoid accepting two parser interpretations of the same request.

Verify signatures and time safely

Compare MAC values with a constant-time primitive where appropriate, select keys by a trusted identifier, and rotate keys with an explicit overlap plan. Validate expiry and allowed clock skew after authenticating the signed fields so unauthenticated values do not drive expensive or revealing behavior.

Use Flashman's URL tool to inspect components, hash tool for public test vectors, diff tool for canonical strings, timestamp converter for expiry, and Base64 tool when a protocol encodes signatures. Never paste live signed URLs that grant access; reduce failures to synthetic fixtures first.

Try these tools