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

bug(rule): rule KMS Key With Full Permissions is creating false alarms #6844

Open
jpriebe opened this issue Jan 3, 2024 · 0 comments
Open
Labels
aws PR related with AWS Cloud bug Something isn't working community Community contribution query New query feature terraform Terraform query

Comments

@jpriebe
Copy link

jpriebe commented Jan 3, 2024

I believe there is a bug in the KMS Key With Full Permissions rule.

A previous issue brought this up, but I don't think the right conclusion was reached.

KMS keys frequently have a policy that allows IAM to manage access to keys. This policy would generally look something like this:

{
    "Version" : "2012-10-17",
    "Statement" : [
      {
        "Sid" : "Enable IAM User Permissions",
        "Effect" : "Allow",
        "Principal" : {
          "AWS" : "arn:aws:iam::ACCOUNTID:root"
        },
        "Action" : "kms:*",
        "Resource" : "*"
      }
   ]
}

This policy statement includes the action kms:*, which is triggering this rule. Despite the fact that it has the string kms:* in the policy, it is not actually granting any KMS permissions to any IAM identities (because the only principal listed is the account principal - the :root principal), and hence, does not represent a security vulernability.

From the documentation:

When the principal in a key policy statement is the account principal, the policy statement doesn't give any IAM principal permission to use the KMS key. Instead, it allows the account to use IAM policies to delegate the permissions specified in the policy statement. This default key policy statement allows the account to use IAM policies to delegate permission for all actions (kms:*) on the KMS key.

Crafting these kinds of policies to avoid a KICS error is not practical, as you have to enumerate all KMS actions in the policy.

Can this rule be modified so that it only triggers on kms:* if there are principals other than the account principal?

In addition, it seems that if the key is defined without a policy, KICS will trigger this error. In the case of a key with no policy, AWS creates a default policy that looks much like the one above. So a key with no policy is not a security risk, either.

@jpriebe jpriebe added bug Something isn't working community Community contribution labels Jan 3, 2024
@github-actions github-actions bot added query New query feature terraform Terraform query aws PR related with AWS Cloud labels Jan 3, 2024
@jpriebe jpriebe changed the title bug(rule): KMS Key With Full Permissions bug(rule): rule KMS Key With Full Permissions is creating false alarms Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws PR related with AWS Cloud bug Something isn't working community Community contribution query New query feature terraform Terraform query
Projects
None yet
Development

No branches or pull requests

1 participant