Skip to content

Commit f0de042

Browse files
authored
Merge pull request ceph#55250 from cbodley/wip-64084
rgw/auth/s3: validate x-amz-content-sha256 for empty payloads Reviewed-by: Daniel Gryniewicz <[email protected]>
2 parents f912e90 + 4bb4947 commit f0de042

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/rgw/rgw_rest_s3.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5755,6 +5755,19 @@ AWSGeneralAbstractor::get_auth_data_v4(const req_state* const s,
57555755
std::placeholders::_3,
57565756
s);
57575757

5758+
// some ops don't expect a request body at all, so never call complete() to
5759+
// validate the payload hash. check empty signed payloads now and return a
5760+
// null completer below
5761+
constexpr std::string_view empty_sha256sum = // echo -n | sha256sum
5762+
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
5763+
if (is_v4_payload_empty(s) &&
5764+
!is_v4_payload_unsigned(exp_payload_hash) &&
5765+
exp_payload_hash != empty_sha256sum) {
5766+
ldpp_dout(s, 4) << "ERROR: empty payload checksum mismatch, expected "
5767+
<< empty_sha256sum << " got " << exp_payload_hash << dendl;
5768+
throw -ERR_AMZ_CONTENT_SHA256_MISMATCH;
5769+
}
5770+
57585771
/* Requests authenticated with the Query Parameters are treated as unsigned.
57595772
* From "Authenticating Requests: Using Query Parameters (AWS Signature
57605773
* Version 4)":

0 commit comments

Comments
 (0)