Hey all, our org has recently grown quite a bit. ...
# aws
s
Hey all, our org has recently grown quite a bit. We have new engineers who are making large contributions to our Terraform codebase (yay!). That being said, I’ve been seeing some quite poor IAM policies for application IRSAs come through (copying policies from AWS docs w/ blanket Allows). There are some cultural/review process issues which can help address this, but I was wondering if anyone had any useful resources for automatically catching quality issues with IAM policies defined via Terraform? I’m thinking along the lines of Spacelift REGO policies or linters which we can run as PR checks?
I suppose this could be helpful for devs using LLM coding assistants https://github.com/awslabs/iam-policy-autopilot
p
There have been so many AWS and third-party IAM policy generation and review tools over the years. I'll be interested to see whether you find some that truly boost security. Although automated tooling can catch obvious problems such as resource
"*"
for actions that support more specific, "resource-level" permissions (ARNs for one or more resource types; service-specific or global condition keys), these tools can't tell people the best remedy, which is going to be specific to the AWS environment in question and to the application. Also problematic are the numerous actions that depend on other actions. Tools are only as good as the documentation. Though AWS has added a "Dependent actions" column to the IAM manual, the information is not 100% complete. There are undocumented holes in the permissions system, such as the reality that granting
ec2:CreateImage
amounts to granting
ec2:RebootInstances
. I've begged AWS for years to at least document that one. (Obviously, reducing existing permissions is fraught, and is done only rarely, for example, when permission for an IAM role to assume itself was removed a few years ago and people had to start adding that permission explicitly if it had been their intention. A palatable solution would be letting action
Deny
on
ec2:RebootInstances
cause
ec2:CreateImage
to fail when called with
NoReboot
set to false.) There is also funny business involving tag-on create, if you use CloudFormation and strict deployment roles. Some cases where a request tag condition key should allow creation of a resource tagged specifically for the intended stack, and a resource tag condition key should allow modification and deletion, will break. Because tag-on-create was gradually added to AWS API methods, I suspect that CloudFormation does not always take advantage of it, but instead still makes some follow-up tagging calls. Last but not least are opaque permissions that just aren't documented. Sometimes, achieving a true least-privilege policy requires trial-and-error with CloudTrail. In short, training, expertise, experience, experimentation, and human collaboration are necessary if you need good-quality, least-privilege IAM policies.