From: Pritha Srivastava Date: Fri, 18 Jun 2021 10:06:10 +0000 (+0530) Subject: rgw/sts: code for returning an error when an IAM policy X-Git-Tag: v16.2.15~26^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4ab5e2e4a537cfb79ed062bb85acbb15a06111f;p=ceph.git rgw/sts: code for returning an error when an IAM policy resource belongs to someone else's tenant. While parsing the policy it discards the resource element, but then when an operation is evaluated, since the resource element is empty, it doesnt evaluate the resource at all and the policy ends up erroneously allowing actions on resources in other tenants. Fixes: https://tracker.ceph.com/issues/51219 Signed-off-by: Pritha Srivastava (cherry picked from commit be42b2cf04def671023b98c811e77e1e357eb38e) --- diff --git a/src/rgw/rgw_iam_policy.cc b/src/rgw/rgw_iam_policy.cc index 15642cc801c6..a63e10e09c75 100644 --- a/src/rgw/rgw_iam_policy.cc +++ b/src/rgw/rgw_iam_policy.cc @@ -558,10 +558,11 @@ bool ParseState::do_string(CephContext* cct, const char* s, size_t l) { a->account = pp->tenant; (w->id == TokenID::Resource ? t->resource : t->notresource) .emplace(std::move(*a)); - } - else + } else { ldout(cct, 0) << "Supplied resource is discarded: " << string(s, l) << dendl; + return false; + } } else if (w->kind == TokenKind::cond_key) { auto& t = pp->policy.statements.back(); if (l > 0 && *s == '$') {