diff --git a/prowler/providers/aws/services/iam/iam_role_cross_service_confused_deputy_prevention/iam_role_cross_service_confused_deputy_prevention.metadata.json b/prowler/providers/aws/services/iam/iam_role_cross_service_confused_deputy_prevention/iam_role_cross_service_confused_deputy_prevention.metadata.json index 54f30ccbcb..0a3cfa4153 100644 --- a/prowler/providers/aws/services/iam/iam_role_cross_service_confused_deputy_prevention/iam_role_cross_service_confused_deputy_prevention.metadata.json +++ b/prowler/providers/aws/services/iam/iam_role_cross_service_confused_deputy_prevention/iam_role_cross_service_confused_deputy_prevention.metadata.json @@ -28,5 +28,5 @@ ], "DependsOn": [], "RelatedTo": [], - "Notes": "CAF Security Epic: IAM" + "Notes": "" } diff --git a/prowler/providers/aws/services/iam/lib/policy.py b/prowler/providers/aws/services/iam/lib/policy.py index f4293bc407..b45dd1bd30 100644 --- a/prowler/providers/aws/services/iam/lib/policy.py +++ b/prowler/providers/aws/services/iam/lib/policy.py @@ -168,17 +168,22 @@ def is_policy_public( in principal.get("CanonicalUser", "") or check_cross_service_confused_deputy and ( - ( # Check if function can be invoked by other AWS services if check_cross_service_confused_deputy is True - ( - ".amazonaws.com" in principal.get("Service", "") - or ".amazon.com" in principal.get("Service", "") - or "*" in principal.get("Service", "") - ) + # Check if function can be invoked by other AWS services if check_cross_service_confused_deputy is True + ( + ".amazonaws.com" in principal.get("Service", "") + or ".amazon.com" in principal.get("Service", "") + or "*" in principal.get("Service", "") + ) + and ( + "secretsmanager.amazonaws.com" + not in principal.get( + "Service", "" + ) # AWS ensures that resources called by SecretsManager are executed in the same AWS account + or "eks.amazonaws.com" + not in principal.get( + "Service", "" + ) # AWS ensures that resources called by EKS are executed in the same AWS account ) - and "secretsmanager.amazonaws.com" - not in principal.get( - "Service", "" - ) # AWS ensures that resources called by SecretsManager are executed in the same AWS account ) ) ) diff --git a/tests/providers/aws/services/iam/lib/policy_test.py b/tests/providers/aws/services/iam/lib/policy_test.py index f07582000b..bac84355ac 100644 --- a/tests/providers/aws/services/iam/lib/policy_test.py +++ b/tests/providers/aws/services/iam/lib/policy_test.py @@ -1923,6 +1923,22 @@ class Test_Policy: } assert not is_policy_public(policy, TRUSTED_AWS_ACCOUNT_NUMBER) + def test_is_policy_public_eks( + self, + ): + policy = { + "Statement": [ + { + "Sid": "test", + "Effect": "Allow", + "Principal": {"Service": "eks.amazonaws.com"}, + "Action": "lambda:GetFunction", + "Resource": "*", + } + ] + } + assert not is_policy_public(policy, TRUSTED_AWS_ACCOUNT_NUMBER) + def test_is_policy_public_cross_cross_service_confused_deputy( self, ):