Repository navigation
src/rgw: amend the s3 error code when x_amz_content_sha256 is error - #55230
climb-mountain123 wants to merge 1 commit into
Conversation
Validate the x_amz_content_sha256 request header. When the length of the header string is not 64 characters and contains characters other than 0-9 and a-f, return InvalidArgument. Fixes: https://tracker.ceph.com/issues/64084 Signed-off-by: daijufang <[email protected]>
| std::string x_amz_content_sha256 = std::string(info.env->get("HTTP_X_AMZ_CONTENT_SHA256", "")); | ||
| std::regex hexRegex("^[0-9a-fA-F]+$"); | ||
| if (x_amz_content_sha256.length() != 64 || !std::regex_match(x_amz_content_sha256, hexRegex)) { | ||
| ldpp_dout(dpp, 10) << "error x-amz-content-sha256 = " << x_amz_content_sha256 << dendl; | ||
| return -EINVAL; |
There was a problem hiding this comment.
don't we have to support all of the special values like UNSIGNED-PAYLOAD etc here? https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html#w33934aab9c25b9c32
There was a problem hiding this comment.
It seems to support the validation of the x-amz-content-sha256 request header in the bool AWSv4ComplSingle::complete() function in the rgw_auth_s3.cc file. The validation of the header and the signature is done separately. However, why is it possible to create a bucket successfully even when x-amz-content-sha256 is incorrect?
There was a problem hiding this comment.
if the CreateBucket request body is empty, we use a null completer instead of AWSv4ComplSingle. see is_v4_payload_empty() in:
Lines 5820 to 5827 in d7e2a32
if the request body isn't empty (for example, from s3cmd mb s3://testbucket --bucket-location=foo which sends a CreateBucketConfiguration xml document), i do see AWSv4ComplSingle being created and later checked in do_aws4_auth_completion:
CONTENT_LENGTH=102
...
req 9584837891480720678 0.000000000s delaying v4 auth
...
req 9584837891480720678 0.001000034s s3:create_bucket NOTICE: call to do_aws4_auth_completion
req 9584837891480720678 0.001000034s s3:create_bucket v4 auth ok -- do_aws4_auth_completion
req 9584837891480720678 0.001000034s s3:create_bucket create bucket input data=<CreateBucketConfiguration><LocationConstraint>foo</LocationConstraint></CreateBucketConfiguration>
There was a problem hiding this comment.
since is_v4_payload_empty() is the only case we're missing, i pushed a draft commit to #55250 that adds it right before that null-completer part. how does that look?
cc @mattbenjamin who's working on other completer changes in #54856
There was a problem hiding this comment.
OK, it is also a good idea.
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
this merged with #55250. thanks for the help @climb-mountain123! |
Validate the x_amz_content_sha256 request header. When the length of the header string is not 64 characters and contains characters other than 0-9 and a-f, return InvalidArgument.
Fixes: https://tracker.ceph.com/issues/64084
Signed-off-by: daijufang [email protected]
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e