> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec-aws-289.md).

# IAM policies allow permissions management or resource exposure without constraints misconfiguration

## IAM policies allow permissions management or resource exposure without constraints misconfiguration detected in code

### Rule Details

|                        |                           |
| ---------------------- | ------------------------- |
| Cortex AppSec Rule ID  | APPSEC\_AWS\_289          |
| Category - Subcategory | IAM - Overly Permissive   |
| Provider               | AWS                       |
| Severity               | HIGH                      |
| Framework              | Terraform, Terraform Plan |

### Impact

This rule is verifying that IAM (Identity and Access Management) permissions don't allow unfettered management of permissions or exposure of resources without any limitations or safeguards.

The risk associated with not adhering to this policy is quite high. If IAM policies allow unconstrained permissions management or unrestricted resource exposure, it creates an opportunity for unauthorized access or manipulation of critical resources, potentially leading to data breaches or compromising the security of the system. Therefore, it's crucial to apply constraints or conditions to manage who can do what and prevent unnecessary exposure of resources.

### How to Fix

*Resource:* aws\_iam\_policy

* *Arguments:* policy

To fix this issue, you need to ensure that your IAM policies are correctly scoped and that resource exposure and permissions management are conducted with constraints. Avoiding overly permissive policies decreases the potential attack surface should any entity with those permissions be compromised.

The above Terraform code creates a custom IAM policy, named "my\_custom\_policy". The policy uses the 'jsonencode' function to clearly define permitted actions. In this case, only 's3:ListBucket' operation is permitted and the resource to which these permissions apply is limited to 'arn:aws:s3:::my\_bucket'. This significantly reduces the attack surface as only one specific resource is exposed with limited permissions.

## Sample IAM Policy

### \[source,go]

resource "aws\_iam\_policy" "my\_custom\_policy" { name = "my\_custom\_policy" description = "A custom policy with only necessary permissions"

### policy = jsonencode( { "Version": "2012-10-17", "Statement": \[ { "Action": \[ "s3:ListBucket" ], "Effect": "Allow", "Resource": "arn:aws:s3:::my\_bucket" } ] } ) }


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec-aws-289.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
