]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Fix bucket validation against POST policies 53758/head
authorJoshua Baergen <jbaergen@digitalocean.com>
Wed, 17 May 2023 18:17:09 +0000 (12:17 -0600)
committerCasey Bodley <cbodley@redhat.com>
Mon, 2 Oct 2023 19:52:05 +0000 (15:52 -0400)
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 <jbaergen@digitalocean.com>
(cherry picked from commit 98bfb71cb38899333deb58dd2562037450fd7fa8)

Conflicts:
src/rgw/rgw_rest_s3.cc get_params() conflict with sse-s3 stuff

src/rgw/rgw_rest_s3.cc

index fe45f6c71d7777d5a1dc80ff52e182680802a871..b86a5e5311c815605a85c8526fcb0822cdbf2db2 100644 (file)
@@ -2661,10 +2661,6 @@ int RGWPostObj_ObjStore_S3::get_params(optional_yield y)
 
   map_qs_metadata(s);
 
-  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;
@@ -2715,6 +2711,10 @@ int RGWPostObj_ObjStore_S3::get_params(optional_yield y)
     env.add_var(part.name, part_str);
   } while (!done);
 
+  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";