fix(copy-object): forward request-payer to the source-size HEAD - #653
Closed
ph-tgs wants to merge 1 commit into
Closed
fix(copy-object): forward request-payer to the source-size HEAD#653ph-tgs wants to merge 1 commit into
ph-tgs wants to merge 1 commit into
Conversation
Every CopyObject meta-request first issues a HEAD on the source object to learn its size, before any small-vs-multipart branching. That HEAD is built from a fresh aws_http_message in aws_s3_get_source_object_size_message_new() and inherited none of the original request's headers, so x-amz-request-payer was never sent on it. Against a Requester Pays bucket the size HEAD is rejected with 403 and the whole copy fails, even though the later bypass / multipart-copy sub-requests do forward the header. Forward x-amz-request-payer onto the source-size HEAD in both the copy_source_uri branch and the x-amz-copy-source fallback branch. Also map the CopyObject source-owner assertion (x-amz-source-expected-bucket-owner) onto the HEAD's x-amz-expected-bucket-owner. The destination x-amz-expected-bucket-owner is intentionally not forwarded: asserting the destination owner on a read of the source object would break legitimate cross-account copies.
1 task
TingDaoK
reviewed
Jul 8, 2026
| if (aws_http_message_add_header(message, header)) { | ||
| return AWS_OP_ERR; | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| } | |
| } | |
| /* Avoid leaking the error code. */ | |
| aws_reset_error(); |
Author
|
Thanks for the format fix! Closing |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: Fixes #652
Description of changes:
Every
CopyObjectmeta-request first issues aHEADon the source object to determine its size, before any small-vs-multipart branching. That HEAD is built from a freshaws_http_messageinaws_s3_get_source_object_size_message_new()and inherited none of the original request's headers, sox-amz-request-payerwas never sent on it. Against a Requester Pays bucket the size-HEAD is rejected with 403 and the whole copy fails — even though the later bypass / multipart-copy sub-requests do forward the header.This change forwards the request-scoped headers from the original request onto the source-size HEAD, in both the
copy_source_uribranch and thex-amz-copy-sourcefallback branch:x-amz-request-payer— forwarded verbatim (the actual 403 fix).x-amz-source-expected-bucket-owner— mapped onto the HEAD'sx-amz-expected-bucket-owner. This is deliberate: on aCopyObject, the source owner is asserted viax-amz-source-expected-bucket-owner, while the plainx-amz-expected-bucket-ownerasserts the destination owner. Forwarding the destination owner onto a read of the source object would newly 403 legitimate cross-account copies, so it is intentionally not forwarded.Testing:
test_s3_get_source_object_size_message_newcovering both branches: assertsx-amz-request-payeris forwarded,x-amz-source-expected-bucket-ownermaps onto the HEAD'sx-amz-expected-bucket-owner, and the destinationx-amz-expected-bucket-owneris not leaked onto the source HEAD.x-amz-request-payerabsent →AWS_ERROR_HTTP_HEADER_NOT_FOUND); with the fix it passes. The existing message-builder tests (copy bypass, MPU create / upload-part / complete / abort, ranged-get) all still pass.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.