Project

General

Profile

Actions

Bug #78697

closed
PS PS

[rgw][sts]: without permission for sts:AssumeRole in role or session policy, able to perform assume role operation with sts creds and get one more set of sts creds

Bug #78697: [rgw][sts]: without permission for sts:AssumeRole in role or session policy, able to perform assume role operation with sts creds and get one more set of sts creds

Added by Pritha Srivastava 4 months ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-1920-g95da1e7718
Released In:
Upkeep Timestamp:
2026-08-11T05:17:45+00:00

Description

[rgw][sts]: without permission for sts:AssumeRole in role or session policy, able to perform assume role operation with sts creds and get one more set of sts creds

this may cause a sts user gain access to resources forever by assuming role again and again by the time they expire
Expiration of sts creds can be bypassed

Version-Release number of selected component (if applicable):
ceph version 18.2.1-195.el9cp

How reproducible:
always

Steps to Reproduce:
1.create a user
2.create a role and attach a role policy to allow all s3 actions

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ radosgw-admin role get --role-name Admin --debug-rgw 0 {
"RoleId": "0f907fa6-59c4-4c44-a47d-269374e10d83",
"RoleName": "Admin",
"Path": "/",
"Arn": "arn:aws:iam:::role/Admin",
"CreateDate": "2024-06-27T05:04:39.285Z",
"MaxSessionDuration": 3600,
"AssumeRolePolicyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"arn:aws:iam:::user/hsm\"]},\"Action\":[\"sts:AssumeRole\"]}]}",
"PermissionPolicies": [ {
"PolicyName": "Admin",
"PolicyValue": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:*\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}"
}
]
}
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

3.Perform the assume role API call and obtain sts creds

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ aws --endpoint-url http://10.0.211.90:80 sts assume-role --role-arn arn:aws:iam:::role/Admin --role-session-name session102 {
"Credentials": {
"AccessKeyId": "pb3wRDu3tqvkRCix3CR",
"SecretAccessKey": "KCL4A9OFRCT36E5GQVMHU97MW4PIZ3QA2C58F3M",
"SessionToken": "9f3OCHAo4Q4rruIQtJ0sdL1NoO9kNlLN+ZSGKiSwSBzXfRoU33oVBHAtlBIWxCCMru0PihZEsJTYxCTmyTrY/omZKmShgHEjh8nSM23pNgP9wwvmbNY8PjIzKbRD0PKp5xpnuwovH70mDBT4b3KkgIHQdB5cxbw/E68CLDKjwBxB2FqXC59oshA1Au20BEQeCz8WzmbAnuBjJiPO4JiagwktHEswvU9PxNhsUS/80ogn7C6CJGmszuLavNCOguwkcuvtNMJlfn65RvULOCnBVq3v9n2Z4ORLRDICdgLehezjy5KKS8s/TXZ8bRTdlxqVRVZTb7OFJqwKN1uxEeiRwQ==",
"Expiration": "2024-06-27T06:16:20.473167954Z"
},
"AssumedRoleUser": {
"Arn": "arn:aws:sts:::assumed-role/Admin/session102"
},
"PackedPolicySize": 0
}
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ cat ~/.aws/credentials
[default]
aws_access_key_id = abc
aws_secret_access_key = abc

[sts_client]
aws_access_key_id = AHJ139Q57UDBF9WYHGPY
aws_secret_access_key = aOG9I5VPRdLCNBD3Rke4vl4ZORNbfc7JiwVDAndA

[sts_creds_profile]
aws_access_key_id = pb3wRDu3tqvkRCix3CR
aws_secret_access_key = KCL4A9OFRCT36E5GQVMHU97MW4PIZ3QA2C58F3M
aws_session_token = 9f3OCHAo4Q4rruIQtJ0sdL1NoO9kNlLN+ZSGKiSwSBzXfRoU33oVBHAtlBIWxCCMru0PihZEsJTYxCTmyTrY/omZKmShgHEjh8nSM23pNgP9wwvmbNY8PjIzKbRD0PKp5xpnuwovH70mDBT4b3KkgIHQdB5cxbw/E68CLDKjwBxB2FqXC59oshA1Au20BEQeCz8WzmbAnuBjJiPO4JiagwktHEswvU9PxNhsUS/80ogn7C6CJGmszuLavNCOguwkcuvtNMJlfn65RvULOCnBVq3v9n2Z4ORLRDICdgLehezjy5KKS8s/TXZ8bRTdlxqVRVZTb7OFJqwKN1uxEeiRwQ==
region = us-east-1
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

5.Attempt to perform assume role with sts creds

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ aws --profile sts_creds_profile --endpoint-url http://10.0.211.90:80 sts assume-role --role-arn arn:aws:iam:::role/Admin --role-session-name session103 {
"Credentials": {
"AccessKeyId": "1FclSM4zDsfxCw4TIgu",
"SecretAccessKey": "4FQJYF3WNUZ8XAG9MC2LS34RWNUHLEXVS3OZ8GW",
"SessionToken": "cwyCD9hQP7gJnLVe+Xq6dAdBNCw9U58Micrn0cBc0oyyhzytrg4Dx5hN66T/eJaJOfqycwqmU7kVJb3+46i6TNL85KxlJ7Vday3QF8K4euldf1ijET1giiA6sKIptk6U5QvM3oxfzB6nE5iozhuYsQ08Jhmllpa5j8sTEGdaxEzo6joAGEvgpzjVl9y4bAOJwfS/dfoXnzwJJYs5iur3IxKq93+EAuGTru/Z8QWBM1rpp/bKRnvr/UPKL1TpT9ywPa3pFYZ+yx3SvaESpyNr58+s659rS1O1kIM49efWazmEl+c81FFvtMNQZrfRrT83b84KdEhOJTaHG+zwUfqNPg==",
"Expiration": "2024-06-27T06:20:13.777690288Z"
},
"AssumedRoleUser": {
"Arn": "arn:aws:sts:::assumed-role/Admin/session103"
},
"PackedPolicySize": 0
}
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ cat ~/.aws/credentials
[default]
aws_access_key_id = abc
aws_secret_access_key = abc

[sts_client]
aws_access_key_id = AHJ139Q57UDBF9WYHGPY
aws_secret_access_key = aOG9I5VPRdLCNBD3Rke4vl4ZORNbfc7JiwVDAndA

[sts_creds_profile]
aws_access_key_id = pb3wRDu3tqvkRCix3CR
aws_secret_access_key = KCL4A9OFRCT36E5GQVMHU97MW4PIZ3QA2C58F3M
aws_session_token = 9f3OCHAo4Q4rruIQtJ0sdL1NoO9kNlLN+ZSGKiSwSBzXfRoU33oVBHAtlBIWxCCMru0PihZEsJTYxCTmyTrY/omZKmShgHEjh8nSM23pNgP9wwvmbNY8PjIzKbRD0PKp5xpnuwovH70mDBT4b3KkgIHQdB5cxbw/E68CLDKjwBxB2FqXC59oshA1Au20BEQeCz8WzmbAnuBjJiPO4JiagwktHEswvU9PxNhsUS/80ogn7C6CJGmszuLavNCOguwkcuvtNMJlfn65RvULOCnBVq3v9n2Z4ORLRDICdgLehezjy5KKS8s/TXZ8bRTdlxqVRVZTb7OFJqwKN1uxEeiRwQ==
region = us-east-1

[sts_creds_profile2]
aws_access_key_id = 1FclSM4zDsfxCw4TIgu
aws_secret_access_key = 4FQJYF3WNUZ8XAG9MC2LS34RWNUHLEXVS3OZ8GW
aws_session_token = cwyCD9hQP7gJnLVe+Xq6dAdBNCw9U58Micrn0cBc0oyyhzytrg4Dx5hN66T/eJaJOfqycwqmU7kVJb3+46i6TNL85KxlJ7Vday3QF8K4euldf1ijET1giiA6sKIptk6U5QvM3oxfzB6nE5iozhuYsQ08Jhmllpa5j8sTEGdaxEzo6joAGEvgpzjVl9y4bAOJwfS/dfoXnzwJJYs5iur3IxKq93+EAuGTru/Z8QWBM1rpp/bKRnvr/UPKL1TpT9ywPa3pFYZ+yx3SvaESpyNr58+s659rS1O1kIM49efWazmEl+c81FFvtMNQZrfRrT83b84KdEhOJTaHG+zwUfqNPg==
region = us-east-1
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

[cephuser@ceph-hsm-71-az2h1h-node8 ~]$ aws --profile sts_creds_profile2 --endpoint-url http://10.0.211.90:80 s3 ls
2024-06-26 13:29:22 sse-bkt1
[cephuser@ceph-hsm-71-az2h1h-node8 ~]$

Actual results:
sts:AssumeRole is successful with sts creds without being allowed in role or session policy

Expected results:
sts:AssumeRole should not be successful with sts creds without being allowed in role or session policy

PS Updated by Pritha Srivastava 4 months ago ยท Edited Actions #1

The trust policy decides whether a role can be assumed or not (and not the role permission/ session policy).
Nevertheless, this is a case of role chaining where the temporary credentials are being used to assume the same role.
rgw::auth::RoleApplier::is_identity() has an else section which during policy evaluation incorrectly allows the user in the trust policy to assume the role. In the sts token for tenant based roles, userid is set to the user assuming the role. And this inadvertently matches the else section below:
else {
string oidc_id;
if (token_attrs.user_id.ns.empty()) {
oidc_id = token_attrs.user_id.id;
} else {
oidc_id = token_attrs.user_id.ns + "$" + token_attrs.user_id.id;
}
return p.get_id() oidc_id
&& p.get_account() token_attrs.user_id.tenant;
}
However the section was added to allow user ARNs to be supported in bucket policy for AssumeRoleWithWebIdentity. Since our policy engine evaluates all kinds of IAM policies using common methods, it is difficult to selectively allow the user only when given in a bucket(resource) policy and only for AssumeRoleWithWebIdentity method.
Since Role chaining is not officially supported in RGW, the best fix is to block role chaining for the time being(it has its own set of rules).

PS Updated by Pritha Srivastava 4 months ago Actions #2

  • Pull request ID set to 70565

JI Updated by J. Eric Ivancich 4 months ago Actions #3

  • Status changed from New to Fix Under Review

UB Updated by Upkeep Bot 4 months ago Actions #4

  • Status changed from Fix Under Review to Resolved
  • Merge Commit set to 95da1e7718b187e89961ecb392f0452189c30b57
  • Fixed In set to v21.3.0-1920-g95da1e7718
  • Upkeep Timestamp set to 2026-08-11T05:17:45+00:00
Actions

Also available in: PDF Atom