Skip to content

Commit b424170

Browse files
committed
fix(seaweedfs): remove BucketVO before IAM policy refresh in deleteBucket
The IAM policy refresh in deleteBucket ran before BucketApiServiceImpl removed the BucketVO row. A concurrent createUser or createBucket policy rebuild (which reads the bucket list from the DB) could re-add the deleted bucket ARN between the exclusion and the row removal, leaving a stale grant that could be exploited if the bucket name was reused. Remove the BucketVO row before the policy refresh so concurrent rebuilds do not see the stale row. BucketApiServiceImpl subsequent _bucketDao.remove is idempotent.
1 parent bd882af commit b424170

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

plugins/storage/object/seaweedfs/src/main/java/org/apache/cloudstack/storage/datastore/driver/SeaweedFSObjectStoreDriverImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,24 @@ public boolean deleteBucket(BucketTO bucket, long storeId) {
508508
throw new CloudRuntimeException(e);
509509
}
510510

511+
// Remove the BucketVO row before refreshing the IAM policy so a
512+
// concurrent createUser/createBucket policy rebuild (which reads the
513+
// bucket list from the DB) cannot re-add the deleted bucket ARN
514+
// between this exclusion and BucketApiServiceImpl's row removal.
515+
// BucketApiServiceImpl's subsequent _bucketDao.remove is idempotent.
516+
for (BucketVO bvo : _bucketDao.listByObjectStoreIdAndAccountId(storeId, accountId)) {
517+
if (bucketName.equals(bvo.getName())) {
518+
_bucketDao.remove(bvo.getId());
519+
break;
520+
}
521+
}
522+
511523
// Refresh the account's IAM policy to drop the deleted bucket.
512524
// Bucket names are reusable, so a stale grant would let the old
513525
// account access a new tenant's bucket with the same name. This
514526
// must succeed; if it fails, the caller sees the exception and can
515527
// retry (the policy refresh is idempotent because the bucket is
516-
// already gone from S3 and excludeBucket still applies).
528+
// already gone from S3 and the DB, so excludeBucket is a no-op).
517529
AmazonIdentityManagement iamClient = getIAMClient(storeId);
518530
updateAccountIAMPolicy(iamClient, storeId, accountId, bucketName);
519531
return true;

0 commit comments

Comments
 (0)