-
Notifications
You must be signed in to change notification settings - Fork 90
IAM | Principal in Bucket Policy of the Account Root User When the Requesting Account Is IAM User #9312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAM | Principal in Bucket Policy of the Account Root User When the Requesting Account Is IAM User #9312
Conversation
WalkthroughAdds an owner-root ARN permission check path to bucket authorization: s3_rest.js computes owner ARN for non-NC deployments and checks it alongside id/name/arn checks; auth_server.js consults the bucket owner's root ARN policy and enforces DENY if that owner-specific check returns DENY. Changes
Sequence DiagramsequenceDiagram
participant Client
participant S3REST as S3 REST Endpoint
participant Auth as AuthServer
participant Policy as Bucket Policy
Client->>S3REST: Request
S3REST->>S3REST: Determine deployment (is_nc_deployment)
S3REST->>S3REST: Check permission_by_id/name/arn (pass {disallow_public_access})
alt Non-NC and account.owner exists
S3REST->>S3REST: Build owner ARN (create_arn_for_root)
S3REST->>Auth: has_bucket_action_permission(owner ARN, {disallow_public_access})
else NC or no owner
S3REST->>Auth: has_bucket_action_permission(normal principal)
end
Auth->>Auth: If account.owner -> compute owner root ARN
Auth->>Policy: has_bucket_policy_permission(owner ARN, {disallow_public_access})
Policy-->>Auth: ALLOW / DENY / NONE
alt Owner DENY
Auth-->>S3REST: false (deny)
S3REST->>Client: Access Denied
else Owner ALLOW or not applicable
Auth-->>S3REST: true/continue
S3REST->>Client: Allow or Deny based on combined checks (id/name/arn/owner/is_owner)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…questing Account Is IAM User 1. Add additional check after the check of bucket policy by principal ARN of the user to also check the permission in account level. 2. Fix permission_by_arn call to has_bucket_policy_permission so the last argument will be an object. Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
3672155 to
8be23f7
Compare
Describe the Problem
Currently, bucket policy principal of ARN was for root user account only, after this change it would be effective for IAM users under this account as well.
Explain the Changes
permission_by_arncall tohas_bucket_policy_permissionso the last argument will be an object.Issues:
List of GAPs:
Testing Instructions:
Note:
nbis an alias that runs the local operator frombuild/_output/bin(alias created bydevenv).kubectl wait --for=condition=available backingstore/noobaa-default-backing-store --timeout=6m -n test1kubectl port-forward -n test1 service/s3 12443:443kubectl port-forward -n test1 service/iam 14443:443nb account create shira-acc01 -n test1 --show-secretsnb account create shira-acc02 -n test1 --show-secretsaccount-1-s3='AWS_ACCESS_KEY=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:12443'account-2-s3='AWS_ACCESS_KEY=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:12443'account-2-iam='AWS_ACCESS_KEY=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:14443'account-1-s3 s3 ls; echo $?account-2-s3 s3 ls; echo $?account-1-s3 s3 mb s3://buc-acc1account-2-s3 s3 mb s3://buc-acc2account-2-iam iam create-user --user-name RobertNote: To validate user creation, you can run
account-2-iam iam list-usersand expect 1 user in the listaccount-2-iam iam create-access-key --user-name Robertaccount-2-iam iam put-user-policy --user-name Robert --policy-name policy_allow_s3 --policy-document file://~/Documents/iam-tests/iam_policies/policy_allow_s3.jsonpolicy_allow_s3.json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:*" ], "Resource": "*" } ] }user-2-s3):alias user-1-s3='AWS_ACCESS_KEY=<access-key> AWS_SECRET_ACCESS_KEY=<secret-key> aws --no-verify-ssl --endpoint-url https://localhost:12443'echo 'test_data' | user-1-s3 s3 cp - s3://buc-acc1/test_object.txt(should not work)has_bucket_action_permissionfunction that was created in theauth_server):user-1-s3 s3 ls s3://buc-acc1(should not work)account-2-s3 s3api get-bucket-acl --bucket buc-acc2and taking the ID.account-1-s3 s3api put-bucket-policy --bucket buc-acc1 --policy file://policy_principal_arn_owner.jsonpolicy_principal_arn_owner.json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::69259fff8b07c200228c4fb3:root" ] }, "Action": [ "s3:*" ], "Resource": "*" } ] }echo 'test_data' | user-1-s3 s3 cp - s3://buc-acc1/test_object.txt(should work)has_bucket_action_permissionfunction that was created in theauth_server):user-1-s3 s3 ls s3://buc-acc1(should not work)Code changes for testing:
src/sdk/object_sdk.jsuses cache expiry of 1 millisecond.const account_cache = new LRUCache({ name: 'AccountCache', - expiry_ms: config.OBJECT_SDK_ACCOUNT_CACHE_EXPIRY_MS, + expiry_ms: 1, //SDSDNotes:
In step 1 - deploying the system, I used
--use-standalone-dbfor simplicity (fewer steps for the system in Ready status).Doc added/updated
Tests added
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.