The title says it all, really. Given an AWS access key and secret, it it possible to get a list of IAM groups to which the user belongs? Is any self-introspection possible with the AWS APIs?
Edit: The question is assuming that no other privileges are granted other than being part of a group itself. For example, this particular IAM user only has permissions to read from an ECR repo and does not have privileges to call list-groups-for-user
.
2
Answers
Yes, it’s possible.
If specific permissions have been granted for the user to run the command.
From the docs
list-groups-for-user
:You can do something like this:
Which sould output something like this:
Full documentation on
list-groups-for-user
is here.If you do not have permission to call
iam:ListGroupsForUser
, oriam:ListGroups
+iam:GetGroup
, then you’re out of luck*. The only API operation that an AWS principal can call without an explicit permission issts:GetCallerIdentity
, which returns the identity of the principal whose credentials were used to call it. There are no permissionless API actions to list the permissions of a principal, list its group memberships, or anything like that.*I’m not sure what errors
iam:AddUserToGroup
andiam:RemoveUserFromGroup
return if the user already is or is not a member of the target group. It’s possible that they might reveal group membership — but if you don’t have permission foriam:ListGroupsForUser
, you’re highly unlikely to have permissions for these.