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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南