On this page
Reordering query parameters breaks a signed URL when the verifier signs an order-sensitive representation of the query string. But not every signing scheme works that way: some canonicalize parameters before calculating the signature, so certain reorderings may be harmless.
This article explains the difference, shows a fictional comparison, and outlines how to diagnose a failure without exposing a real signed link.
Key Takeaways
- A signature protects the request representation defined by its signing scheme, not necessarily the URL as a browser or application interprets it.
- Depending on the scheme, parameter order, duplicate parameters, percent-encoding, and other request details can affect verification.
- A textual URL comparison can identify changes, but it cannot verify a signature or establish that a link is still authorized.
- Treat a signed URL as a credential: avoid posting it in logs, tickets, or online tools.
What a signed URL protects
A signed URL typically contains request information and a signature generated using a secret or private key. The receiving service reconstructs the data to be verified and checks the signature according to its scheme. It may also enforce conditions such as an expiration time or permitted HTTP method.
Many schemes first build a canonical request: a specified representation of selected request components. Depending on the provider, this can include the HTTP method, path, query names and values, selected headers, and a representation of the body. The scheme defines details such as how query components are encoded, which parameters participate, and whether they are sorted.
The crucial point is that these rules are provider-specific. A service that sorts query parameters during canonicalization may produce the same canonical query for two differently ordered URLs. A service that signs the raw query string or preserves certain ordering may not.
Advertisement
A fictional example of reordering query parameters
Imagine a download service whose custom scheme signs the HTTP method, path, and query string exactly as written, excluding the sig parameter itself. The following examples use a reserved fictional hostname and a placeholder signature; they are not usable links or real credentials.
Original:
https://downloads.example.invalid/download?file=report.pdf&expires=2000000000&sig=illustrative
Reordered:
https://downloads.example.invalid/download?expires=2000000000&file=report.pdf&sig=illustrative
Both URLs contain the same two non-signature parameters. But under this imaginary scheme, the query strings supplied to the signature calculation differ:
file=report.pdf&expires=2000000000
expires=2000000000&file=report.pdf
If the signature was generated for the first representation, the verifier would reject the second. By contrast, a different scheme that sorts these parameters into the same canonical order could accept either ordering, assuming all its other requirements are met.
This example is conceptual: illustrative is not a calculated signature, and these URLs have not been tested.
Changes that can affect verification
Reordering is only one possible source of a mismatch. Check the signing scheme before deciding which differences matter:
- Names and values: Adding, removing, renaming, or changing a parameter may change the signed data. An extra tracking parameter is not automatically safe.
- Encoding: A signer and verifier may require a particular treatment of percent-encoded characters, spaces, or reserved characters. Re-encoding a URL can change its signed representation even when it appears to carry the same value.
- Duplicate names: A query such as
tag=a&tag=bis not necessarily interchangeable withtag=b&tag=a. A parser that collapses duplicates can also discard information required for verification. - Empty and missing values:
flag,flag=, and an absentflagcan be treated differently. Do not assume a provider considers them equivalent. - Other signed components: The HTTP method, path, host, headers, or body may be relevant even when the visible query string is unchanged.
- Authorization conditions: A signature can be mathematically valid while the request is no longer permitted, for example because an expiry or another access condition has failed.
An unchanged URL also does not guarantee a successful request. The recipient may apply additional authorization checks or require request components that are not visible in the link.
Diagnose a signed-link failure safely
- Preserve the original. Capture the exact URL as issued in a secure environment, along with the intended HTTP method and any required headers. Do not decode and rebuild it as part of the capture.
- Compare the request path. Check whether a redirect, proxy, application, or URL-building library changed the path, host, query order, encoding, or parameters between issuance and use.
- Inspect a redacted or fictional example. A textual diff can reveal changed characters, duplicate parameters, or missing fields. Redaction can itself change the signed data, so a redacted comparison cannot verify the original signature.
- Check the provider's rules. Find the official documentation for the exact signing mechanism and operation. Determine how it canonicalizes the query, which request components it signs, and how it handles expiry and redirects.
- Reproduce only in an authorized environment. Generate a fresh test link using test resources and credentials. Compare the canonical request or diagnostic details if your implementation or provider makes them available. Avoid logging secrets or complete production links.
- Check authorization separately. Confirm the link is within its permitted lifetime and that the requested operation and relevant access policies allow the request.
This article could not consult a provider's official signing documentation in this run. Consult the documentation for your actual provider and signing scheme before treating any ordering or encoding change as safe; the fictional scheme above is not a specification for a real provider.
Advertisement
Common Mistakes
- Assuming all query strings are order-independent. Even if an application accepts parameters in any order, its signature verifier may use a different representation.
- Assuming all signatures preserve raw order. Canonical sorting can make some reorderings harmless; duplicate-name and encoding rules still need checking.
- Parsing and rebuilding a signed URL casually. A library may reorder parameters, normalize encoding, or lose duplicates. Preserve the issued URL unless the signing scheme explicitly permits the transformation.
- Treating a diff as a security check. A comparison shows text differences; it does not authenticate a signature, check expiry, or prove authorization.
- Sharing complete signed URLs for debugging. Anyone with access to a still-valid link may be able to use it within its permitted scope. Use fictional examples and secure diagnostic channels.
Best Practices
Keep signed links opaque between the issuer and the client where possible. If a transformation is unavoidable, validate it against the exact provider's rules and test it with newly generated, limited-scope links. For webhooks and API requests, inspect the specific signature scheme too: it may protect a body, headers, or a request target rather than a signed URL alone.
Conclusion
Reordering query parameters breaks a signed URL only when the change affects what that particular scheme verifies. Compare the exact request representations, then use the provider's signing rules and authorization checks to determine the cause.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.