Skip to content

Commit fbb7c3d

Browse files
committed
rgw: donot allow NotPrincipal with Allow Effect
NotPrincipal must be used with "Effect":"Deny". Using it with "Effect":"Allow" is not supported. cf. https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notprincipal.html Fixes: https://tracker.ceph.com/issues/67047 Signed-off-by: Seena Fallah <[email protected]>
1 parent 34257b8 commit fbb7c3d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/rgw/rgw_iam_policy.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,10 @@ bool ParseState::do_string(CephContext* cct, const char* s, size_t l) {
701701
return false;
702702
}
703703
} else if (w->kind == TokenKind::cond_key) {
704-
auto& t = pp->policy.statements.back();
705704
if (l > 0 && *s == '$') {
706705
if (l >= 2 && *(s+1) == '{') {
707706
if (l > 0 && *(s+l-1) == '}') {
708-
t.conditions.back().isruntime = true;
707+
t->conditions.back().isruntime = true;
709708
} else {
710709
annotate(fmt::format("Invalid interpolation `{}`.",
711710
std::string_view{s, l}));
@@ -717,7 +716,7 @@ bool ParseState::do_string(CephContext* cct, const char* s, size_t l) {
717716
return false;
718717
}
719718
}
720-
t.conditions.back().vals.emplace_back(s, l);
719+
t->conditions.back().vals.emplace_back(s, l);
721720

722721
// Principals
723722

@@ -756,6 +755,13 @@ bool ParseState::do_string(CephContext* cct, const char* s, size_t l) {
756755
return false;
757756
}
758757

758+
// NotPrincipal must be used with "Effect":"Deny". Using it with "Effect":"Allow" is not supported.
759+
// cf. https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notprincipal.html
760+
if (t && t->effect == Effect::Allow && !t->noprinc.empty()) {
761+
annotate("Allow with NotPrincipal is not allowed.");
762+
return false;
763+
}
764+
759765
return true;
760766
}
761767

0 commit comments

Comments
 (0)