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 réponse
1
Réponse acceptée

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
répondu il y a 2 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions