Skip to content

Restrict S3 307 redirects to trusted targets - #3514

Merged
dscpinheiro merged 4 commits into
version-3from
stangade/s3-redirect-target-validation
Dec 2, 2026
Merged

dscpinheiro merged 4 commits into
version-3from
stangade/s3-redirect-target-validation

Conversation

@sankettangade

@sankettangade sankettangade commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

The S3 redirects plugin followed any 307 to the URL in the Location header and re-signed the request for it. This change:

  • Always follows same-origin 307s (same scheme, host and port). Relative Location values are resolved first.
  • Follows 307s to another origin only to an HTTPS Amazon S3 host in the client's partition, on the default port, and only when the endpoint is SDK-resolved or is itself an HTTPS Amazon S3 host.
  • Raises Aws::S3::Errors::Http307Error for redirects it does not follow, the same error as follow_redirects: false.
  • Drops the old Host header on cross-host redirects, so the request is re-signed for the new host.

Compatibility

S3-compatible services behind a custom :endpoint that send 307s to another host, scheme or port now get Http307Error. Configure the final endpoint directly instead.

Testing

  • New spec/plugins/redirects_spec.rb (27 examples).
  • Full aws-sdk-s3 suite passes.
  • Dry Run: f17febeb-fae8-47f7-9b3d-d129ace75740

Follow 307 redirects only to the same origin, or to HTTPS Amazon S3 hosts in the same partition when the endpoint is SDK-resolved.
Follow cross-host 307s from a configured endpoint that is itself an HTTPS S3 host, and require an S3 label on both hosts.
Compare the partition of the redirect host's region, since aws and aws-us-gov share DNS suffixes, and use customer-focused changelog wording.
Trust a configured S3 endpoint over HTTP or HTTPS while still refusing HTTPS to HTTP downgrades, and never trust S3 website endpoints.
@sankettangade
sankettangade force-pushed the stangade/s3-redirect-target-validation branch from 82ee61d to b1d1be3 Compare December 2, 2026 18:54
@dscpinheiro
dscpinheiro merged commit f106852 into version-3 Dec 2, 2026
34 of 35 checks passed
@dscpinheiro
dscpinheiro deleted the stangade/s3-redirect-target-validation branch December 2, 2026 20:11
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.

3 participants