-
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
base: master
Are you sure you want to change the base?
IAM | Principal in Bucket Policy of the Account Root User When the Requesting Account Is IAM User #9312
Conversation
…quest Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
Signed-off-by: shirady <[email protected]>
WalkthroughImplements ownership-based ARN permission checks in bucket authorization with conditional logic for NC versus non-NC deployments. Modifies the S3 REST endpoint to compute account identifiers differently and adds a new owner-based ARN permission check path. Updates auth_server to verify bucket owner root account permissions and enforce DENY when owner-based checks fail. Changes
Sequence DiagramsequenceDiagram
participant Client
participant S3REST as S3 REST<br/>Endpoint
participant AuthServer
participant Policy as Bucket Policy
Client->>S3REST: Request
S3REST->>S3REST: Determine deployment<br/>(NC vs non-NC)
alt Non-NC Deployment
S3REST->>S3REST: permission_by_arn<br/>(disallow_public_access)
S3REST->>AuthServer: has_bucket_action_permission<br/>(including owner check)
else NC Deployment
S3REST->>S3REST: permission_by_arn<br/>(disallow_public_access)
S3REST->>S3REST: Standard checks
end
AuthServer->>AuthServer: Check if<br/>account.owner exists
alt Account has owner
AuthServer->>AuthServer: Compute owner ARN
AuthServer->>Policy: Query owner ARN<br/>permissions
Policy-->>AuthServer: Policy result
alt Owner DENY
AuthServer-->>S3REST: Return false
S3REST->>Client: Access Denied
else Owner ALLOW
AuthServer-->>S3REST: Return true
end
else No owner
AuthServer->>AuthServer: Use existing<br/>is_owner check
AuthServer-->>S3REST: Return result
end
S3REST->>Client: Grant/Deny Access
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
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
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-keys --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):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 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": "*" } ] }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