Skip to content

validate region from S3 redirect response in S3RegionRedirector#3722

Open
metsw24-max wants to merge 1 commit into
boto:developfrom
metsw24-max:s3-redirect-validate-region
Open

validate region from S3 redirect response in S3RegionRedirector#3722
metsw24-max wants to merge 1 commit into
boto:developfrom
metsw24-max:s3-redirect-validate-region

Conversation

@metsw24-max

Copy link
Copy Markdown

Unvalidated bucket region in S3RegionRedirector

The deprecated S3RegionRedirector.get_bucket_region returns the region taken from a redirect response (the x-amz-bucket-region header, the error body Region, or the HeadBucket fallback) as-is, whereas its replacement S3RegionRedirectorv2 already runs validate_region_name on the same value. The two classes therefore disagree on whether a server-supplied region is checked. That region then feeds endpoint resolution, the rewritten request URL and the SigV4 signing region, so an untrusted or misbehaving endpoint can push an arbitrary string through this path. I have kept the change to the v2 behaviour and applied the same validate_region_name call; nothing else in the flow changes. Added unit cover for the three sources. The class is deprecated, but it is still importable and used by third parties, so bringing it in line seems worthwhile.

S3RegionRedirectorv2 already runs validate_region_name on the region taken from a redirect response; apply the same check in the deprecated S3RegionRedirector so the server-supplied value is validated before it reaches endpoint resolution and request signing.
@metsw24-max

Copy link
Copy Markdown
Author

any update?

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.

1 participant