Skip to content

Comments

rgw: prevent data sync from replicating to buckets not owned by the user#61828

Merged
cbodley merged 3 commits intoceph:mainfrom
clwluvw:datasync-useracl
Mar 11, 2025
Merged

rgw: prevent data sync from replicating to buckets not owned by the user#61828
cbodley merged 3 commits intoceph:mainfrom
clwluvw:datasync-useracl

Conversation

@clwluvw
Copy link
Member

@clwluvw clwluvw commented Feb 14, 2025

Issue https://tracker.ceph.com/issues/68884 revealed that because user_acl is initialized by default in RGWUserPermHandler::Init with the same identity, calling verify_bucket_permission_no_policy() would mistakenly allow the request since the user ACL matches the identity. Removing the default creation of user_acl would align the behavior with other S3 operations (leaving user_acl uninitialized) to prevent unauthorized data replication.

Fixes: https://tracker.ceph.com/issues/69972

Issue https://tracker.ceph.com/issues/68884 revealed that because
user_acl is initialized by default in RGWUserPermHandler::Init with
the same identity, calling verify_bucket_permission_no_policy()
would mistakenly allow the request since the user ACL matches the
identity. Removing the default creation of user_acl would align the
behavior with other S3 operations to prevent unauthorized data replication.

Fixes: https://tracker.ceph.com/issues/69972
Signed-off-by: Seena Fallah <[email protected]>
@cbodley
Copy link
Contributor

cbodley commented Feb 14, 2025

what would it take to get test coverage for this stuff? cc @smanjara

@clwluvw
Copy link
Member Author

clwluvw commented Feb 14, 2025

what would it take to get test coverage for this stuff? cc @smanjara

I guess with the current test setup testing sync policies would be tricky as the cluster is running with symmetric replication rules so all buckets are replicated to other zones with system users. I'm not sure how it would react if we apply a policy on a bucket while the global policy is something else. basically, that is what we wanted to clarify by the design doc you wanted to propose so we can make a line here eventually. So my preference is to add all this coverage for sync policies after the design is there and perhaps would be only for zonegroup replication.

@smanjara
Copy link
Contributor

what would it take to get test coverage for this stuff? cc @smanjara

I guess with the current test setup testing sync policies would be tricky as the cluster is running with symmetric replication rules so all buckets are replicated to other zones with system users. I'm not sure how it would react if we apply a policy on a bucket while the global policy is something else. basically, that is what we wanted to clarify by the design doc you wanted to propose so we can make a line here eventually. So my preference is to add all this coverage for sync policies after the design is there and perhaps would be only for zonegroup replication.

to cover this pr and also #60685 we could keep the zonegroup policy in allowed state, build whatever bucket sync policies you need, including user creation and attaching policies to it to test user mode sync, and apply it to just that testcase and tear it down at the end using remove_sync_policy_group. this won't affect other test cases.
for sync policies you could do something like this: test_sync_flow_directional_zonegroup_select and for creating a new user and managing boto connection, I added a small test in d9b0e78
maybe you could do something similar because our boto connections for multisite tests are hardcoded to use the multisite admin user.

@github-actions github-actions bot added the tests label Feb 14, 2025
@clwluvw
Copy link
Member Author

clwluvw commented Feb 15, 2025

jenkins test api

@smanjara
Copy link
Contributor

thanks for adding the testcases. looks great!

@smanjara smanjara self-requested a review February 17, 2025 17:42
@cbodley
Copy link
Contributor

cbodley commented Mar 6, 2025

arg = ['--account-id', user.account]
arg += master_zone.zone_args()
master_zone.cluster.admin(['account', 'create'] + arg)
user = multisite.User('rgw-multisite-test-user')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this removed account support and broke account-related tests:

ERROR: rgw_multi.tests.test_role_sync
ERROR: rgw_multi.tests.test_role_delete_sync
ERROR: rgw_multi.tests.test_account_metadata_sync

each failed with an error like this:

botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the CreateRole operation: None

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have two possible solutions for this:

  1. We retain the default user as accounted and create two additional users—let's call them non_account_user and non_account_alt_user—to use for PutBucketReplication tests.
  2. We could utilize the Role field in BucketReplicationConfiguration with a non-role ARN (though this might not be the preferred approach). When the user is associated with an account, we prompt for a UID from their account, check if the UID belongs to the account, and use it as the UID (not sure if anything would break if suddenly that UID is deleted and/or shifted to another account). This would allow us to bypass the -ERR_NOT_IMPLEMENTED here: ad51353, eliminating the need for differentiation at this point.

What are your thoughts on these options?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the first approach - leaving the API sane. let me know if you think otherwise.

clwluvw added 2 commits March 7, 2025 18:02
Create a user and alt user without account to test PutBucketReplication
scenarios as account is not supported to call that API yet.

Signed-off-by: Seena Fallah <[email protected]>
Test policies created through PutBucketReplication API, whether they
respect the uid used in the policies.

Signed-off-by: Seena Fallah <[email protected]>
@cbodley
Copy link
Contributor

cbodley commented Mar 10, 2025

@cbodley cbodley merged commit c8c15bd into ceph:main Mar 11, 2025
11 checks passed
@sentrycephcom
Copy link

sentrycephcom bot commented Mar 19, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ AssertionError rgw_multi.tests in meta_sync_status View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants