Skip to content

fix(cloudflare/worker): don't merge query params into external redirects#288

Merged
smecsia merged 1 commit into
mainfrom
fix/cf-worker-preserve-external-redirect-query
May 21, 2026
Merged

fix(cloudflare/worker): don't merge query params into external redirects#288
smecsia merged 1 commit into
mainfrom
fix/cf-worker-preserve-external-redirect-query

Conversation

@universe-ops

Copy link
Copy Markdown
Contributor

The Cloudflare worker proxies the upstream Lambda's redirect responses back to the browser. Previously it merged the original request's query string into every redirect target, including external ones like S3 presigned URLs.

This broke any service that issues a 3xx to an S3 presigned URL (e.g. storage-service): the extra param (e.g. ?secret=...) changes the canonical query string, so X-Amz-Signature no longer matches and S3 returns "SignatureDoesNotMatch". It also leaked the original request's secrets to whatever third party we redirected to.

Move the query-merge inside the same target.hostname === overrideHost branch as the hostname rewrite — same-upstream redirects still merge, external redirects pass through untouched.

The Cloudflare worker proxies the upstream Lambda's redirect responses
back to the browser. Previously it merged the original request's query
string into every redirect target, including external ones like S3
presigned URLs.

This broke any service that issues a 3xx to an S3 presigned URL (e.g.
storage-service): the extra param (e.g. ?secret=...) changes the
canonical query string, so X-Amz-Signature no longer matches and S3
returns "SignatureDoesNotMatch". It also leaked the original request's
secrets to whatever third party we redirected to.

Move the query-merge inside the same `target.hostname === overrideHost`
branch as the hostname rewrite — same-upstream redirects still merge,
external redirects pass through untouched.
@smecsia
smecsia merged commit efe40be into main May 21, 2026
9 of 10 checks passed
@github-actions

Copy link
Copy Markdown

Semgrep Scan Results

Repository: api | Commit: 0ab036a

Check Status Details
⚠️ Semgrep Warning 10 warning(s), 10 total

Scanned at 2026-05-21 20:35 UTC

@github-actions

Copy link
Copy Markdown

Security Scan Results

Repository: api | Commit: 0ab036a

Check Status Details
✅ Secret Scan Pass No secrets detected
✅ Dependencies (Trivy) Pass 0 total (no critical/high)
✅ Dependencies (Grype) Pass 0 total (no critical/high)
📦 SBOM Generated 528 components (CycloneDX)

Scanned at 2026-05-21 20:36 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants