Skip to content

Commit 4bb4947

Browse files
committed
rgw/auth/s3: validate x-amz-content-sha256 for empty payloads
when is_v4_payload_empty(), we return a null completer so never try to validate the x-amz-content-sha256 for signed payloads. add this checksum comparison to get_auth_data_v4() before we create the completer Signed-off-by: Casey Bodley <[email protected]>
1 parent d7e2a32 commit 4bb4947

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
@@ -5805,6 +5805,19 @@ AWSGeneralAbstractor::get_auth_data_v4(const req_state* const s,
58055805
std::placeholders::_3,
58065806
s);
58075807

5808+
// some ops don't expect a request body at all, so never call complete() to
5809+
// validate the payload hash. check empty signed payloads now and return a
5810+
// null completer below
5811+
constexpr std::string_view empty_sha256sum = // echo -n | sha256sum
5812+
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
5813+
if (is_v4_payload_empty(s) &&
5814+
!is_v4_payload_unsigned(exp_payload_hash) &&
5815+
exp_payload_hash != empty_sha256sum) {
5816+
ldpp_dout(s, 4) << "ERROR: empty payload checksum mismatch, expected "
5817+
<< empty_sha256sum << " got " << exp_payload_hash << dendl;
5818+
throw -ERR_AMZ_CONTENT_SHA256_MISMATCH;
5819+
}
5820+
58085821
/* Requests authenticated with the Query Parameters are treated as unsigned.
58095822
* From "Authenticating Requests: Using Query Parameters (AWS Signature
58105823
* Version 4)":

0 commit comments

Comments
 (0)