From b204c2dbecc4fe00934289ad486158889fe77a05 Mon Sep 17 00:00:00 2001 From: Poorna Date: Fri, 13 Jan 2023 04:16:00 -0800 Subject: [PATCH] fix: enforce deny on DeleteVersionAction (#16409) --- cmd/auth-handler.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/auth-handler.go b/cmd/auth-handler.go index 688b40edc..d0c9c0e11 100644 --- a/cmd/auth-handler.go +++ b/cmd/auth-handler.go @@ -371,6 +371,7 @@ func authorizeRequest(ctx context.Context, r *http.Request, action policy.Action region := reqInfo.Region bucket := reqInfo.BucketName object := reqInfo.ObjectName + versionID := reqInfo.VersionID if action != policy.ListAllMyBucketsAction && cred.AccessKey == "" { // Anonymous checks are not meant for ListAllBuckets action @@ -404,7 +405,21 @@ func authorizeRequest(ctx context.Context, r *http.Request, action policy.Action return ErrAccessDenied } - + if action == policy.DeleteObjectAction && versionID != "" { + if !globalIAMSys.IsAllowed(iampolicy.Args{ + AccountName: cred.AccessKey, + Groups: cred.Groups, + Action: iampolicy.Action(policy.DeleteObjectVersionAction), + BucketName: bucket, + ConditionValues: getConditionValues(r, "", cred.AccessKey, cred.Claims), + ObjectName: object, + IsOwner: owner, + Claims: cred.Claims, + DenyOnly: true, + }) { // Request is not allowed if Deny action on DeleteObjectVersionAction + return ErrAccessDenied + } + } if globalIAMSys.IsAllowed(iampolicy.Args{ AccountName: cred.AccessKey, Groups: cred.Groups,