Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IAM action-specific resources lint #1940

Open
jonathanmorley opened this issue Mar 11, 2021 · 6 comments
Open

IAM action-specific resources lint #1940

jonathanmorley opened this issue Mar 11, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@jonathanmorley
Copy link
Contributor

IAM actions can either accept a resource to be scoped by, or they should be passed * (for all resources).

It would be nice to have an informational lint rule that would be able to check statements used in IAM resources, and based on the action, decide whether the resource is correct (* for actions that cannot be scoped, and NOT * for those that can)

@kddejong
Copy link
Contributor

If I'm understandingly this correct.

This is valid. Because these actions don't work against resources.

{
  "Effect": "Allow",
  "Action": [
    "aws-portal:ViewBilling"
  ],
  "Resource": "*"
}

This is valid. Because these actions work against resources

{
  "Effect":"Allow",
  "Action": [
     "ec2:AuthorizeSecurityGroupIngress",
     "ec2:AuthorizeSecurityGroupEgress",
     "ec2:RevokeSecurityGroupIngress",
     "ec2:RevokeSecurityGroupEgress"
  ],
  "Resource": "arn:aws:ec2:region:account:security-group/*"
}

This is invalid. These actions work against resources but the user used a *.

{
  "Effect":"Allow",
  "Action": [
     "ec2:AuthorizeSecurityGroupIngress",
     "ec2:AuthorizeSecurityGroupEgress",
     "ec2:RevokeSecurityGroupIngress",
     "ec2:RevokeSecurityGroupEgress"
  ],
  "Resource": "*"
}

@PatMyron
Copy link
Contributor

PatMyron commented Mar 11, 2021

(somewhat related issue: #1117)

remember seeing a similar conversation for cfripper/cfn_nag/cfn-guard/parliament/@iann0036's projects

@omkhegde @iann0036 @0xdabbad00 @phelewski @oscarbc96 anyone have a link / remember where?

@oscarbc96
Copy link

In CFRipper, we finally created this list of actions that only accept wildcards. https://github.com/Skyscanner/cfripper/blob/master/cfripper/cloudformation_actions_only_accepts_wildcard.py

@iann0036
Copy link
Contributor

Parliament should tell you what actions are resource-less per the SAR (though that does have some missing actions, somewhat captured here.

@benbridts
Copy link
Contributor

Another option is to use the Access Analyzer policy validation. That would require AWS credentials, and might run into issues with !Sub and !Ref, but maybe some findings can be ignored if those are present.

@PatMyron PatMyron added the enhancement New feature or request label May 18, 2021
@PatMyron
Copy link
Contributor

Another Python library validating IAM policies in CloudFormation templates:
https://github.com/awslabs/aws-cloudformation-iam-policy-validator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants