EFS File system policy with IAM Instance Profile collision

0

There is a EFS volume with below as the File System Policy

{
    "Version": "2012-10-17",
    "Id": "read-only-example-policy02",
    "Statement": [
        {
            "Sid": "efsReadOnlyFS",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<account_id>:role/InstanceProfile"
            },
            "Action": "elasticfilesystem:ClientMount",
            "Resource": "arn:aws:elasticfilesystem:us-east-2:<account_id>:file-system/fs-id"
        }
    ]
}

The Role InstaceProfile is the role attached to a EC2 Instance. Now, this Instance Profile has IAM policy with elasticfilesystem:* which grant it ALL ACCESS on the EFS.

Now, even though the File System policy makes it Read only, I am still able to mount the EFS and write files into it. Shouldn't the File System Policy take precedence over the Instance profile permissions?

1 回答
1
已接受的回答

Good question!

In this case, your File System policy is a resource policy and the instance policy would be considered an IAM Identity Policy. For resources in the same account, these are treated as a logical or. It is also important to remember policy evaluation logic.

First, Explicit Denies are evaluated, then Explicit Allows, then Implicit Denies.

Explicit Denies --> Explicit Allows --> Implicit Denies

In this case, your EFS policy is an Allow for read, so if the instance policy has an explicit allow for writing, it will not be denied. If you're looking to secure the EFS volume further, you would need to use an explicit deny on the policy itself (and you can use this in conjunction with allows).

jsonc
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则