Skip to content

Commit b3b4362

Browse files
committed
IAM | Bucket policy principal is account ARN - when user sends the request
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent 8204d2a commit b3b4362

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/endpoint/s3/s3_rest.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ async function authorize_request_policy(req) {
296296
let permission_by_id;
297297
let permission_by_name;
298298
let permission_by_arn;
299+
let permission_by_arn_owner;
299300

300301
// In NC, we allow principal to be:
301302
// 1. account name (for backwards compatibility)
@@ -327,7 +328,18 @@ async function authorize_request_policy(req) {
327328
}
328329
if (permission_by_arn === "DENY") throw new S3Error(S3Error.AccessDenied);
329330

330-
if ((permission_by_id === "ALLOW" || permission_by_name === "ALLOW" || permission_by_arn === "ALLOW") || is_owner) return;
331+
// ARN check for users under the account
332+
// ARN check is not implemented in NC yet
333+
if (!is_nc_deployment && account.owner !== undefined) {
334+
const owner_account_identifier_arn = s3_bucket_policy_utils.get_bucket_policy_principal_arn(account.owner);
335+
permission_by_arn_owner = await s3_bucket_policy_utils.has_bucket_policy_permission(
336+
s3_policy, owner_account_identifier_arn, method, arn_path, req, public_access_block?.restrict_public_buckets
337+
);
338+
dbg.log3('authorize_request_policy: permission_by_arn_owner', permission_by_arn_owner);
339+
if (permission_by_arn_owner === "DENY") throw new S3Error(S3Error.AccessDenied);
340+
}
341+
if ((permission_by_id === "ALLOW" || permission_by_name === "ALLOW" ||
342+
permission_by_arn === "ALLOW" || permission_by_arn_owner === "ALLOW") || is_owner) return;
331343

332344
throw new S3Error(S3Error.AccessDenied);
333345
}

0 commit comments

Comments
 (0)