# Policies and Permissions

### IAM Policy

Permission policy is an authorization mechanism. Hence, until the policy is attached to an AWS Identity, that identity cannot do anything.

AWS Identities are authorized to perform or forbidden to perform certain actions based on these policies. This is possible a single policy can include multiple permissions or statements. Also, multiple statements in policies are evaluated in OR logic

IAM Policy is a JSON-formatted document in which permissions are listed. It consists of 4 different categories such as Effect, Action, Resource and Condition where Effect can be to allow or not to allow, action can be create or delete, resource can be AWS service and condition can answer whether to perform or not based on if it is true or not. These policies itself are like template. These needs to be attached to an AWS identity like user, group or IAM Roles for them to shape up to become permissions.

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FVKf19XKJQ6vyYZPeGUaD%2Fimage.png?alt=media&#x26;token=3a1cc59f-984e-48db-9f3a-4da6069baebd" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Note, for ease of creation of an IAM policy, one can always try using the following:

<https://awspolicygen.s3.amazonaws.com/policygen.html>
{% endhint %}

IAM policy is written in Access Policy Language (a fancy name indeed for a JSON Document)

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F7EBToWg1C3mFqngyKbZs%2Fimage.png?alt=media&#x26;token=494e568f-530d-4c9c-9964-82168eb91f06" alt=""><figcaption></figcaption></figure>

Note that there is a Version: 2012-10-17 statement in the above policy. It states when AWS created this version of policy writing. there was 2008 also, which was older version.&#x20;

Also, statement ID (SID) is optional

The Action follows Noun-Verb format (example: s3(noun):Get-Object(ACL)

The Condition follows Key:Value pair (example:"Condition":{"StringsEquals":{"aws:username":"Senapati"}}) and value is case sensitive by default, otherwise condition can be set to ignore case for value of Senapati. Also Policy condition types can be global condition keys or service-specific condition keys, examples of which is as follows:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FWrCYwg4Kl92zcusF6Yjw%2Fimage.png?alt=media&#x26;token=cd2049ba-13cc-4aa4-81d3-f63e47fcf894" alt=""><figcaption><p>Source: <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html</a></p></figcaption></figure>

Please note that for these policies to take effect, these need to be attached to an IAM Identity like User, Group or Role, thereby becoming permissions for the attached identity.

### Policy Creation

Steps to create a policy are as follows:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FBDHKyvkvA2eEsmSQS34v%2Fimage.png?alt=media&#x26;token=b345e076-5ae5-422b-a2e9-86fb30b47381" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FKjvDCkBG9dbocvREFubR%2Fimage.png?alt=media&#x26;token=74231f12-459c-4048-8ac4-a7a3f722ae38" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FI8r1NcuLkbv2XuwVUrYJ%2Fimage.png?alt=media&#x26;token=2471565f-b50d-4ea4-8b40-f1646bdea463" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FfvPUpxAALQBewSEssv39%2Fimage.png?alt=media&#x26;token=15900b4a-3e4a-481f-b399-1cf3fc10e501" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FkPhfv8K9RxEPZPOI3RFe%2Fimage.png?alt=media&#x26;token=bee7a932-9919-4525-8c54-33e7531affaf" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FHIzMPqelODRIYtllAcK4%2Fimage.png?alt=media&#x26;token=d14aa977-f841-4d46-a859-1b93849a87c4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FF3YkaCBtMQPOFHudQTlO%2Fimage.png?alt=media&#x26;token=6353f9bc-9570-4073-b9a3-4f63e7ef6406" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F0h9o7NoAeP9EH3tNFxzF%2Fimage.png?alt=media&#x26;token=eebfab21-63b6-4681-bd91-79d123453e3d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F5gMnsncz4AE5itWFk3Ug%2Fimage.png?alt=media&#x26;token=07b3fca3-dc26-4205-b9e4-9893c0c98755" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FgxUKLGDnqiIG7AC3V56U%2Fimage.png?alt=media&#x26;token=cc9f53f5-9279-4b08-bef0-d62c253624c2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F8FThYp48yPA5twEBSXtO%2Fimage.png?alt=media&#x26;token=dd10dfdd-9fe0-48d1-955b-f86c0621d6db" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Personal Interpretation, the AWS IAM policies are evaluated on every action, especially for Console Access, meaning:

Let's just a user ABC is logged onto the console and has the permission in a policy attached to him/her that allows to upload a file inside S3 bucket. Now, if the admin or any user with change permissions over IAM removes the policy that allows ABC to upload files, then he/she would be unable to do so, the next time they want to perform the file upload permission (PutObject) inside the s3 bucket.&#x20;
{% endhint %}

Note that there is a&#x20;

### Summaries in IAM&#x20;

The policy summary have hyperlinks to Service Summary and it has hyperlinks to action summary. These summaries are an absolute gold when it comes to analysing and understanding a particular IAM policy and can be navigated as shown below:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FDMB8Ru6Sirab1YgcXk4K%2Fimage.png?alt=media&#x26;token=6788057b-4356-4e5e-bf1e-eb4ccef35ff4" alt=""><figcaption><p>Source: <a href="https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/policy_summaries-pol-sum.png">https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/policy_summaries-pol-sum.png</a></p></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FPiwZjcQduZQ2xcY5T1sd%2Fimage.png?alt=media&#x26;token=e088e81d-f1a3-4630-b1d9-c06a5d3ca271" alt=""><figcaption></figcaption></figure>

### NotResource, NotAction

NotResource is exact opposite of Resource in an IAM policy, With NottResource, one can setup policy like Everything except the one mentioned in NotResource

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FJ8JsjXG00LrtaIOYUlFv%2Fimage.png?alt=media&#x26;token=97ccd8c1-c5f9-4269-9688-160e9c7d0251" alt=""><figcaption></figcaption></figure>

NotAction matches everything except the specified action. When effect is allow, it allows all actions except the ones mentioned in NotAction. When effect is deny, it denies all actions except the ones mentioned in NotAction.

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2Fb1GQ9as1WFlMTQxIGVnz%2Fimage.png?alt=media&#x26;token=e0e414ea-801c-421c-99b4-20c8288770a9" alt=""><figcaption></figcaption></figure>

### Types of Identity-based Policies

* **Managed Policies**
  * [x] These managed policies are independent resources with their own unique ARNs
  * [x] They can be attached to multiple AWS Identities
  * [x] It can be further categorized as **AWS managed** (cannot be edited or updated by anyone including root except AWS and used for common use cases\[also referred as **Job Functions - which are like full job role that can be assigned to a person**]) or **Customer managed** (as the name suggests, they are managed by the customer of that particular AWS account)
  * [x] It has version control, i.e., it is possible to have multiple versions of a particular policy. Max number of policy versions are 5.
  * [x] The newest version of the policy is default, so if one wants to choose another policy version to be applied, simply change that version as default.
* **Inline Policies**
  * [x] They are embedded in a single identity.
  * [x] They are inline hence cannot be attached to other identity.
  * [x] They are also managed by the customer themselves, hence customizable at any given time

### Policy Evaluation (I)

{% hint style="info" %}
**An AWS identity with multiple policies also follows OR logic when evaluating the final access**&#x20;
{% endhint %}

IAM policy works with the following precedence: Explicit Deny -> Explicit Allow -> finally Implicit Deny. Example: A new user is created and no access was given during creation time, so access to all services in AWS are implicitly denied, post that, if the user is allowed to access certain things, then that would be the case of explicitly allowing or granting them permissions to do certain task, and then if the same user is explicitly denied to access anything then takes the highest priority for denying access to certain AWS services or resources as applicable. This is particularly useful when one has to temporary ban the usage of AWS account by assigning Explicit Deny on the account that prevents the usage of the account.

The evaluation logic flowchart whenever any action would be attempted to be performed is as follows:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F2XroHWCriXpuaEZq7SVS%2Fimage.png?alt=media&#x26;token=d384cdeb-5fe7-43fa-8f30-229b6d59f307" alt=""><figcaption><p>Source: <a href="https://docs.aws.amazon.com/images/sns/latest/dg/images/AccessPolicyLanguage_Evaluation_Flow.gif">https://docs.aws.amazon.com/images/sns/latest/dg/images/AccessPolicyLanguage_Evaluation_Flow.gif</a></p></figcaption></figure>

The evaluation logic can be summarized as follows:

* By default all requests are denied.&#x20;
* An explicit allow in any permissions policy/ies override the default.
* An organization's SCP, IAM permissions boundary or a session policy overrides the allow.&#x20;
* In short, they must all allow the request for anything to be permitted
* An Explicit deny in any policy overrides any allows

The decision making algorithm flowchart for policy evaluation considering all relevant policies can be as follows:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FpRvT9WjuER85yGXC3fLO%2Fimage.png?alt=media&#x26;token=aca6f58a-b095-4aba-bbd7-d0a9d0eedd46" alt=""><figcaption><p>Source: <a href="https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/PolicyEvaluationHorizontal111621.png">https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/PolicyEvaluationHorizontal111621.png</a></p></figcaption></figure>

### Policy Simulator

Policy simulator allows a way to test and simulate policy changes without applying them. Testing can be done based on policies attached to AWS IAM Identities or based on services, actions and resources. It can be useful to test overlapping policies to understand that if an action is allowed or denied and which statement works and which is preceded

Head over to [https://policysim.aws.amazon.com/home/index.jsp#](https://policysim.aws.amazon.com/home/index.jsp)&#x20;

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F8mJ5yoHaBrfWyFuePT3m%2Fimage.png?alt=media&#x26;token=ada9535f-7228-4ba7-b60d-0b10fda2f3cf" alt=""><figcaption></figcaption></figure>

### Permission Boundaries

It indicates maximum permissions that an IAM identity can have and can only be attached to an IAM user or role. Note that there can be one permission boundary per IAM identity. This is useful to prevent accidental application of IAM policies to an AWS IAM identity in case there are multiple people in organization that has the privileges to change or add permissions to a Identity.

It works in conjunction with Permission policy as shown below:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FItrloBVv0iLDk8GiccY4%2Fimage.png?alt=media&#x26;token=3e7ac875-ef40-434f-bb6c-8558e6f0b60b" alt=""><figcaption><p>Source: <a href="https://securityboulevard.com/2023/10/aws-permission-boundary-what-is-it-and-how-to-use-it/">https://securityboulevard.com/2023/10/aws-permission-boundary-what-is-it-and-how-to-use-it/</a></p></figcaption></figure>

One can setup a boundary as shown below:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FdL7AlZ1wXdAIQ6rlsLsz%2Fimage.png?alt=media&#x26;token=81a44597-5012-43b6-b351-5920f86e4bcc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FmlXOrHTro2YCpBiFXPGF%2Fimage.png?alt=media&#x26;token=55aa063d-d877-4092-b869-3251c8b654d1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2F12uClRCUaI4eC80Qpntq%2Fimage.png?alt=media&#x26;token=294532e5-3132-4522-a594-f07be226cac0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2Fwa53kXomaXrYLkt47cvy%2Fimage.png?alt=media&#x26;token=81476e62-4fff-4a75-8f4a-0bfb966c8d11" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2Fj2OYcHvnGVqXTzjdOwEO%2Fimage.png?alt=media&#x26;token=a5b8015b-d4f0-4867-b957-8e9bcfafd9a5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2Fe6bBAQJexHDv6LsQNaYY%2Fimage.png?alt=media&#x26;token=588ded5d-f823-4668-8982-3f283db71ab4" alt=""><figcaption></figcaption></figure>

So effectively whoever assumes the role of s3kacommander, will only have the common access which would be that of s3bucketaccess policy simply because it has less permissions and they are the only actions rather than the overly permissive policy of tests3fullaccess and therefore senapati will only be able to access based on the condition set even when senapati assumes the role of s3kacommander

### Other Policy Types

The entire discussion that happened above is for Identity-based policies. Other tyes of policies are as follows:

* **Resource-based Policies**: Available for certain resources such as [S3 ](https://notes.radifine.com/aws/aws-storage-services/s3#resource-based-policy)or SQS
* **Organization Service Control Policies:**
  * [x] To understand this, it is recommended that one reads about [AWS Organizations](https://notes.radifine.com/aws/aws-identity-and-access-management/aws-organizations) first and understand OU or Organization Unit
  * [x] Sometimes despite privileges, a user is unable to execute commands. This is despite the fact one can have privileges. The reason for that is SCP i.e., Service Control Policies which is always set in Management Account
  * [x] It sets the maximum permissions for an OU and limits permission for entities in member accounts, including each AWS root Account
* **Access Control Lists**: Relevant to storage and buckets and ACLs in firewall (especially for public access). It defines which principals in another account can assume a role.
* **Session Policies:**
  * [x] When one is assuming a role, session policy can be applied to limit what all role can do. It is similar to permission boundary, but there is a difference based on applicability. Session policy is applied only when one is assuming a role. So if the organization wants to limit what a user assuming a role can and can't do, then it can be defined in session policy.

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FZtLO6SH6N185BmioZ3zg%2F1.png?alt=media&#x26;token=db4714fb-2f54-4322-bfed-52516fe9e186" alt=""><figcaption></figcaption></figure>

When an IAM user assumes a role to access a s3, if s3 has a resource policy, and if it mentions Resource ARN, then internally the resource policy is converted to IAM policy to provide access accordingly. If it is session ARN, then it is not converted.

* [x] As per above diagram Scenario 1: A resource-based policy can specify the ARN of the user or role as a principal. In that case, the permissions from the resource-based policy are added to the role or user's identity-based policy **before the session is created**. The session policy limits the total permissions granted by the resource-based policy and the identity-based policy. The resulting session's permissions are the intersection of the session policies and the resource-based policies plus the intersection of the session policies and identity-based policies.

```json
// Identity-Based Policy for DataAccessRole:


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}

// Resource-Based Policy on example-bucket:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/DataAccessRole"
      },
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::example-bucket/specific-object"
    }
  ]
}

// Session Policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": "arn:aws:s3:::example-bucket/specific-object"
    }
  ]
}

// Effective Permissions
The effective permissions will be limited to:
Actions: s3:GetObject, s3:PutObject on arn:aws:s3:::example-bucket/specific-object
```

* [x] As per above diagram Scenario 2: A resource-based policy can specify the ARN of the session as a principal. In that case, the permissions from the resource-based policy are **added after the session is created**. The resource-based policy permissions are not limited by the session policy. The resulting session has all the permissions of the resource-based policy *plus* the intersection of the identity-based policy and the session policy.

<pre class="language-json"><code class="lang-json">// Identity-Based Policy (attached to DataAccessRole):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}

<strong>// Resource-Based Policy on example-bucket:
</strong>
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:sts::123456789012:assumed-role/DataAccessRole/*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::example-bucket/*"
    }
  ]
}

// Session Policy (applied during the session):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket",
        "s3:PutObject"
      ],
      "Resource": [
        "arn:aws:s3:::example-bucket",
        "arn:aws:s3:::example-bucket/*"
      ]
    }
  ]
}

// Effective Permissions
The effective permissions will be limited to:
Actions: s3:GetObject, s3:PutObject, s3:ListBucket for all objects in arn:aws:s3:::example-bucket
</code></pre>

* [x] As per above diagram Scenario 3: A permissions boundary can set the maximum permissions for a user or role that is used to create a session. In that case, the resulting session's permissions are the intersection of the session policy, the permissions boundary, and the identity-based policy. However, a permissions boundary does not limit permissions granted by a resource-based policy that specifies the ARN of the resulting session.

```json
// Identity-Based Policy for DataAccessRole:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "*"
    }
  ]
}

// Permissions Boundary:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::example-bucket/*"
    }
  ]
}

// Session Policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": "arn:aws:s3:::example-bucket/specific-object"
    }
  ]
}

//Effective Permissions:
The effective permissions will be limited to:
Actions: s3:GetObject, s3:PutObject on arn:aws:s3:::example-bucket/specific-object
```

{% hint style="info" %}
Note that **Resource groups** and **Tag editor** are another methods to provide access via IAM
{% endhint %}

### Policy Evaluation (II)

The evaluation logic can be summarized as follows:

* By default all requests are denied.&#x20;
* An explicit allow in any permissions policy/ies override the default.
* An organization's SCP, IAM permissions boundary or a session policy overrides the allow.&#x20;
* In short, they must all allow the request for anything to be permitted
* An Explicit deny in any policy overrides any allows

The decision making algorithm flowchart for policy evaluation considering all relevant policies can be as follows:

<figure><img src="https://3681896347-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjfQTFfcSjS8MYnjfKw2c%2Fuploads%2FpRvT9WjuER85yGXC3fLO%2Fimage.png?alt=media&#x26;token=aca6f58a-b095-4aba-bbd7-d0a9d0eedd46" alt=""><figcaption><p>Source: <a href="https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/PolicyEvaluationHorizontal111621.png">https://docs.aws.amazon.com/images/IAM/latest/UserGuide/images/PolicyEvaluationHorizontal111621.png</a></p></figcaption></figure>

###
