From: Joshua Baergen Date: Wed, 17 May 2023 18:17:09 +0000 (-0600) Subject: rgw: Fix bucket validation against POST policies X-Git-Tag: v18.2.1~188^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1a96d61224b4067acd9d2439716776f5a726d591;p=ceph.git rgw: Fix bucket validation against POST policies It's possible that user could provide a form part as a part of a POST object upload that uses 'bucket' as a key; in this case, it was overriding what was being set in the validation env (which is the real bucket being modified). The result of this is that a user could actually upload to any bucket accessible by the specified access key by matching the bucket in the POST policy in said POST form part. Fix this simply by setting the bucket to the correct value after the POST form parts are processed, ignoring the form part above if specified. Fixes: https://tracker.ceph.com/issues/63004 Signed-off-by: Joshua Baergen (cherry picked from commit 98bfb71cb38899333deb58dd2562037450fd7fa8) --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index d16bf7f4c4a3a..005c086f8c84f 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2870,10 +2870,6 @@ int RGWPostObj_ObjStore_S3::get_params(optional_yield y) map_qs_metadata(s, false); - ldpp_dout(this, 20) << "adding bucket to policy env: " << s->bucket->get_name() - << dendl; - env.add_var("bucket", s->bucket->get_name()); - bool done; do { struct post_form_part part; @@ -2938,6 +2934,10 @@ int RGWPostObj_ObjStore_S3::get_params(optional_yield y) return r; } + ldpp_dout(this, 20) << "adding bucket to policy env: " << s->bucket->get_name() + << dendl; + env.add_var("bucket", s->bucket->get_name()); + string object_str; if (!part_str(parts, "key", &object_str)) { err_msg = "Key not specified";