Short answer: treat a 403 on a presigned download URL as a signature disagreement about the exact object-storage bytes and time used for signing, then trace those inputs before changing permissions.

That rule matters in a fintech system serving generated reports to authenticated customers. A link can be authorized for the right tenant and still fail because a proxy decoded %2F, a worker's clock is ahead, or the signer used a different object key than the uploader. The storage service is doing what it should: it verifies a precise request, not your intention.

The decision record: preserve these invariants

I start the design with four invariants. The authenticated request determines tenant_id; that value selects a storage prefix, never a user-supplied path. The object key is stored as data and passed unchanged to the signer. The application signs and serves from UTC time. Finally, the download response never reveals a bucket listing or another tenant's metadata.

The export worker writes an immutable object such as tenants/acme/reports/2026-09-07/statement-1842.csv. The API records the canonical key and a checksum in its database. At download time it checks the caller's tenant and report row, creates a short-lived URL, and logs a request identifier rather than the full query string (the signature itself is a credential).

Here is the useful comparison I put in an architecture decision record:

Option Isolation boundary Failure you can diagnose Good fit
Direct presigned URL Storage key plus signed parameters Canonical-request mismatch, expiry, clock drift Browser downloads of private exports
Application streaming proxy Application authorization on every byte Proxy timeout, range handling, memory pressure Strict egress policy or per-download auditing
Public object with random name Name secrecy URL leakage and retention mistakes Non-sensitive, disposable artifacts
Signed CDN URL CDN policy and storage origin Policy/key-group mismatch Large files with edge caching

For customer reports, the first option is usually the smallest attack surface when the key prefix is tenant-scoped and the URL lifetime is conservative. It is not suitable when every byte must pass through a data-loss-prevention scanner; use an application proxy there. That trade-off belongs in the record, before the first 403 arrives.

How do presigned download URLs, 403 signatures, expiry, and object keys fail together?

Signature verification is an equality test. The signer canonicalizes the HTTP method, path, selected headers, and query parameters, hashes that string, and derives a signature with a secret key. The verifier repeats the process. One character of difference is enough for a 403.

The path is the common trap. A key containing a space, +, Unicode, or a literal %2F has several representations. A framework may decode once while a reverse proxy decodes again. Do not build a URL by concatenating a bucket, slash, and raw filename. Keep the key canonical in storage, let the storage SDK perform its canonical encoding, and treat the returned URL as opaque. In Node.js, pass the same string to upload and signing; avoid a second decodeURIComponent in a download controller. I also compare the URL's path before and after every gateway hop, because a helpful normalization middleware can turn one valid byte sequence into a different one while preserving a perfectly plausible filename in logs. That mismatch is easy to miss during a code review and obvious in a hex dump.

It failed.

I keep a redacted trace beside each export: method, canonical key hash, signer region, X-Amz-Date, X-Amz-Expires, and the server's UTC offset. Never log X-Amz-Signature, access keys, or the complete URL. A 403 then becomes a comparison exercise instead of a guess.

This tiny Python helper checks the inputs without contacting storage:

from datetime import datetime, timezone from urllib.parse import parse_qs, urlsplit def inspect_presigned_url(raw_url: str, now: datetime) -> dict: query = parse_qs(urlsplit(raw_url).query) signed_at = query.get("X-Amz-Date", [""])[0] expires = int(query.get("X-Amz-Expires", ["0"])[0]) issued = datetime.strptime(signed_at, "%Y%m%dT%H%M%SZ").replace(tzinfo=timezone.utc) age_seconds = (now.astimezone(timezone.utc) - issued).total_seconds() return { "has_signature": bool(query.get("X-Amz-Signature")), "age_seconds": age_seconds, "expires_seconds": expires, "expired": age_seconds > expires, "credential_present": bool(query.get("X-Amz-Credential")), } 

If expired is false but the request still fails, compare the canonical path and method next. A GET signed in the worker and followed as a HEAD by a client library is a different request. A browser can also add a header that was included in the signed-header list but changed in transit. Strip optional headers from the signing policy unless you truly need them.

Clock skew deserves its own alarm. NTP keeps machines close, but containers, suspended laptops, and isolated build workers drift. Compare the signer timestamp with a trusted UTC source and alert before the allowed window is consumed. A longer expiry hides the symptom and extends the blast radius of a leaked link; it does not repair a bad clock.

A tenant-isolated export path that stays observable

The API should resolve a report ID to a database row, not accept an arbitrary object key from the browser. The row contains the tenant and canonical key. Authorization happens before signing, and the audit event records success or denial without secrets.

from datetime import timedelta from hashlib import sha256 def create_download_link(user, report_id, reports, signer, clock): report = reports.find(report_id) if report is None or report.tenant_id != user.tenant_id: raise PermissionError("report is not available") # The key came from the database, after tenant authorization. expires_in = timedelta(minutes=5) url = signer.presign_get_object(key=report.object_key, expires=expires_in) audit("report_link_issued", user_id=user.id, report_id=report.id, key_hash=sha256(report.object_key.encode()).hexdigest()) return url 

The critical path has two independent clocks: the report's creation time and the URL's issue time. Use the latter for expiry. If a queue retries an old job, it must not silently overwrite the canonical key with a newly encoded variant. Make the object write idempotent, then sign only after the database says the object is complete.

For operations, split metrics by tenant and outcome: authorization denial, signer rejection, expired link, and client cancellation. A spike in signature mismatches across every tenant points to deployment or clock configuration. One tenant alone suggests a key with unusual bytes or a bad migration. This distinction saves hours.

What should the team test before blaming storage?

Build a matrix around bytes and time, not just a happy-path filename. Include spaces, +, %, repeated slashes, non-ASCII names, and a key that literally contains %2F. Generate and consume each URL through the same proxy path used in production. Assert that the resolved tenant prefix matches the database row and that a URL for tenant A cannot fetch tenant B's report.

Freeze the clock in unit tests. Add an integration test at the exact expiry boundary, then one second after it. Test GET and HEAD separately. Test a client that preserves the URL byte-for-byte and another that normalizes it, so the team can see which layer changed the request.

There is a practical limit here: storage providers differ in canonicalization details and maximum expiry windows. Your mileage may vary across SDK versions and gateways, so pin the signer version, document the provider's signing specification, and run a canary against the real endpoint during upgrades. A generic retry on 403 is dangerous; retry only after classifying the cause, and never mint a new link for an unauthorized report.

Keep the rejected option visible. Making every object public and hiding the name removes signature mismatches, but it turns a leaked export URL into an authorization bypass and complicates retention. It is valid for public documentation or non-sensitive assets, not customer financial reports.

References