Skip to content

rgw/auth: don't require x-amz-content-sha256 in signed headers - #71292

Merged
cbodley merged 1 commit into
ceph:mainfrom
cbodley:wip-79803
Aug 25, 2026
Merged

cbodley merged 1 commit into
ceph:mainfrom
cbodley:wip-79803

Conversation

@cbodley

@cbodley cbodley commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

aws sigv4 does not require s3 requests to sign x-amz-content-sha256 because it's already present in the canonical request as HashedPayload

Fixes: https://tracker.ceph.com/issues/79803

Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions github-actions Bot added the rgw label Aug 24, 2026
Comment thread src/rgw/rgw_auth_s3.cc Resolved
@cbodley
cbodley marked this pull request as ready for review August 24, 2026 16:03
@cbodley
cbodley requested a review from a team as a code owner August 24, 2026 16:03
@cbodley

cbodley commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

i'd like to add a test case to validate this and catch future regressions

@cbodley

cbodley commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

updated with test cases that include and omit this header from the signature. both test cases pass with the fix applied. without the fix, the test case that omits the header fails as expected:

FAILED s3tests/functional/test_headers.py::test_sigv4_without_signed_content_sha256 - assert 403 == 200

@cbodley

cbodley commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

The following tests FAILED:
289 - unittest_rgw_auth_sigv4 (Failed)

that's not on my branch, so i'll rebase and debug

aws sigv4 does not require s3 requests to sign x-amz-content-sha256
because it's already present in the canonical request as HashedPayload

Fixes: https://tracker.ceph.com/issues/79803

Signed-off-by: Casey Bodley <[email protected]>
Comment on lines -204 to -207
/* botocore's query signer doesnt sign x-amz-content-sha256, so a
* presigned URL is exactly where forging it would matter. */
EXPECT_FALSE(canonicalize_presigned(
{{"HTTP_X_AMZ_CONTENT_SHA256", "UNSIGNED-PAYLOAD"}}, boto2));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @elliotcourant, my fix was causing this new test case to fail

the s3 doc for this query-based auth in https://docs.aws.amazon.com/AmazonS3/latest/developerguide/sigv4-query-string-auth.html just uses a hard-coded UNSIGNED-PAYLOAD for the PayloadHash part of the canonical request, so x-amz-content-sha256 is not consulted there. only for header-based auth in https://docs.aws.amazon.com/AmazonS3/latest/developerguide/sigv4-auth-using-authorization-header.html does it say that x-amz-content-sha256 is required

in rgw, i do see that AWSGeneralAbstractor::get_auth_data_v4() calls get_v4_exp_payload_hash() even when bool using_qs is true, so will calculate the server signature based on the value of x-amz-content-sha256 if it's given. but i assume that any value other than UNSIGNED-PAYLOAD, whether forged or not, would lead to a signature mismatch

so i still think it's safe to remove this enforcement that x-amz-content-sha256 is signed, along with this test case. what do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that you are correct yes, that test was a bit overdone just to be safe; but with the other test expects remaining i think its still good and this is safe to remove.

Sorry this caused a headache here!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Elliot - no worries, the test reflected what the code was enforcing. i just didn't want to change it without your ack

@cbodley

cbodley commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@cbodley

cbodley commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor Author

passed qa in https://pulpito.ceph.com/cbodley-2026-08-24_20:23:05-rgw-wip-79803-distro-default-trial/ with 3 known issues:

verified that new test cases ran and passed:

2026-08-24T21:00:36.528 INFO:teuthology.orchestra.run.trial116.stdout:s3tests/functional/test_headers.py::test_sigv4_with_signed_content_sha256 PASSED [ 3%]
2026-08-24T21:00:36.598 INFO:teuthology.orchestra.run.trial116.stdout:s3tests/functional/test_headers.py::test_sigv4_without_signed_content_sha256 PASSED [ 3%]

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants