`boto3` and the AWS CLI fail to simulate an ELB policy

0

We used a simulator to check whether a policy has the permission to perform specific actions on specific ELB resources. The simulator returned implicitDeny instead of allowed. This result is erroneous, because the actions and the resources in the policy document were the same as the parameters of the simulator. To test this, we attached the policy to a role and used this role to perform the actions on the resources in a live AWS environment, and we were successful.

We will now attempt to reproduce this error as minimally as possible.

Both the AWS SDK for Python (a.k.a. boto3)

import boto3

policy_input_list = [
    """{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "elasticloadbalancing:AddTags"
            ],
            "Resource": [
                "arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*"
            ]
        }
    ]
}"""
]
action_names = ["elasticloadbalancing:AddTags"]
resource_arns = ["arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*"]

boto3.client("iam").simulate_custom_policy(
    PolicyInputList=policy_input_list,
    ActionNames=action_names,
    ResourceArns=resource_arns,
)

and the AWS CLI

policy_input_list='{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["elasticloadbalancing:AddTags"],"Resource":["arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*"]}]}'
action_names='elasticloadbalancing:AddTags'
resource_arns='arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*'

aws iam simulate-custom-policy \
    --policy-input-list $policy_input_list \
    --action-names $action_names \
    --resource-arns $resource_arns

erroneously evaluate this to implicitDeny.

Interestingly, the IAM Policy Simulator

IAM Policy Simulator

correctly evaluates this to allowed.

The problematic statement

{
    "Effect": "Allow",
    "Action": [
        "elasticloadbalancing:AddTags",
        "elasticloadbalancing:RemoveTags"
    ],
    "Resource": [
        "arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*",
        "arn:aws:elasticloadbalancing:*:*:listener/app/*/*/*",
        "arn:aws:elasticloadbalancing:*:*:listener-rule/net/*/*/*",
        "arn:aws:elasticloadbalancing:*:*:listener-rule/app/*/*/*"
    ]
}

originates from the policy document of the AWS Load Balancer Controller (https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json). Any combination of these actions and resources (and only them) will be evaluated correctly by the IAM Policy Simulator, but incorrectly by boto3 and the AWS CLI.

Note that we are using the latest versions of boto3 (v1.27.72) and the AWS CLI (v1.27.72).

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠