So went through the AWS Article and I got the concept for why these are needed (basically “Hello? You are about to create these sensitive items user, role etc..are you sure?”)
What Im trying to understand is this:
When any of your IAM resources have a custom name, such as a RoleName then CAPABILITY_NAMED_IAM is required.
What do they mean by this? Why does RoleName become “custom” thus requiring CAPABILITY_NAMED_IAM and in that sense whats an example for CAPABILITY_IAM?
“If an IAM role exists - such as a Service Linked Role - use CAPABILITY_IAM when referencing that role in CF. But if you are creating a BRAND NEW ROLE - use CAPABILITY_NAMED_IAM”?
If you define a role without a name, Cloudformation will generate one for you. To create a role like this, you need CAPABILITY_IAM.
If for whatever reason you can’t or don’t want to use the autogenerated name, you need to have CAPABILITY_NAMED_IAM to specify your own name.
I assume that allowing a CF template to create custom named roles is more dangerous and therefore requires a separate capability, but I’m not actually sure what that danger is. Can’t find any info on that by Googling, but it is what it is and I’ll trust that AWS has a reason for it.
AWS::IAM::Role has not always supported the RoleName property. When it was first launched, the only option was CloudFormation generating a random name for you - hence the CAPABILITY_IAM capability.
When custom RoleName functionality was added, AWS must have deemed sufficiently powerful that it warranted special confirmations - hence the new capability.
One reason for having these as distinct capabilities is to allow users to deploy a stack which includes IAM roles, without giving them the ability to arbitrarily name these roles. This is important to prevent privilege escalation; if an application or AWS service is expecting a specific role name, and that role was somehow deleted, then any user with the ability to create named roles could create a new role with the same name and * permissions and the service/application would just use the new role. That user could then use the app/service to perform actions on their behalf that they otherwise wouldn’t be able to do on their own.
Nice..I love the use case based explanation. Question though - at the end of the day - this is just to provide an acknowledgement correct? So in theory any user that has access to CF and has permissions to create a CF stack can simply add this CLI parameter and create a stack which will create the role and the app/service will be able to perform the actions? Im feel like missing something basic…
Is that correct though? If I create a role and then give that role to a service, then delete the role, the name of the role in the service is a bunch of random letters. A new role with the same name would not be recognized by the service.
Now if you personally were referring to a role by name in one of your own apps, it could result in a privilege escalation. But I don’t see too many scenarios where that would happen
Is that correct though? If I create a role and then give that role to a service, then delete the role, the name of the role in the service is a bunch of random letters. A new role with the same name would not be recognized by the service.
Now if you personally were referring to a role by name in one of your own apps, it could result in a privilege escalation. But I don’t see too many scenarios where that would happen
It’s less of an issue with services themselves now that service linked roles have become more prevalent, but can still be an issue with services that pass roles to their resources, e.g. EC2 instance roles, ECS execution roles.