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

feat(rego): add query to check iam policy to invoke lambda #5542

Conversation

jplanckeel
Copy link
Contributor

Proposed Changes
Since June 2022 IAM policy to invoke lambda need to defined two ressources :

  • One with only the name of the lambda function
  • a second one with the name of the function and a * for the version

I propose to create a good practice rule to indicate this

  1. Starting at the IAM Console, go to Policies.
  2. Look for policies including user managed policies, roles, users and user groups with inline policies that match Resource field as function ARN. For example, If the function ARN is arn:aws:lambda:aws-region:acct-id:function:my-function, find policies where Resource field contains "function:my-function".
  3. For the matching policies, select the "Edit Policy" button and select JSON.
    3.1. To allow access to function (unqualified ARN) and its sub-resources, add another statement with ":" to function name by changing the Resource field to "Resource": ["arn:aws:lambda:aws-region:acct-id:function:my-function", "arn:aws:lambda:aws-region:acct-id:function:my-function:"]
    3.2. To allow access to function (unqualified ARN) only, use Resource as "Resource": ["arn:aws:lambda:aws-region:acct-id:myFunction"] .
  4. Select Review Policy and Save.

I submit this contribution under the Apache-2.0 license.

@rafaela-soares rafaela-soares added the community Community contribution label Jun 30, 2022
Copy link
Contributor

@rafaela-soares rafaela-soares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @jplanckeel!

Thank you so much for contributing to KICS 🚀

Please, see the suggestions:

Copy link
Contributor

@rafaela-soares rafaela-soares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @jplanckeel!

We need to update the positive_expected_result.json:

@rjegoncalves rjegoncalves requested a review from nunolope5 July 5, 2022 15:15
Copy link
Contributor

@rafaela-soares rafaela-soares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

I will wait only for our security team to approve the severity and category.

nunolope5
nunolope5 previously approved these changes Jul 7, 2022
Copy link

@nunolope5 nunolope5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing the proposed new rule and associated Severity, Category, and Description my only comment is regarding the query name, it should be "Lambda IAM InvokeFunction Misconfigured".

Co-authored-by: Rafaela Soares <[email protected]>
Copy link
Contributor

@rafaela-soares rafaela-soares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Thank you so much for contributing, @jplanckeel!

@rafaela-soares rafaela-soares merged commit f3d5f40 into Checkmarx:master Jul 11, 2022
@jplanckeel jplanckeel deleted the feat/add-query-iam-lambda-ressources-invocation branch July 11, 2022 10:14
@rafaela-soares rafaela-soares added the query New query feature label Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution query New query feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants