> For the complete documentation index, see [llms.txt](https://docs.forestall.io/fsprotect/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.forestall.io/fsprotect/edges/aws/aws_can_set_default_policy_version.md).

# AWS\_CAN\_SET\_DEFAULT\_POLICY\_VERSION

## Summary

|                                |                                                                     |
| ------------------------------ | ------------------------------------------------------------------- |
| **FSProtect ACL Alias**        | AWS\_CAN\_SET\_DEFAULT\_POLICY\_VERSION                             |
| **Edge Type**                  | Attack Path                                                         |
| **Affected Object Types**      | IAM Users, IAM Roles, Customer Managed Policies                     |
| **Exploitation Certainty**     | Certain                                                             |
| **AWS IAM Action / Condition** | `iam:SetDefaultPolicyVersion` on target customer-managed policy ARN |

## Description

`AWS_CAN_SET_DEFAULT_POLICY_VERSION` represents the ability to change which version of a customer-managed IAM policy is active.

This is a dangerous escalation primitive because IAM evaluates only the **default** version of a managed policy. If an attacker can set default version, they can:

* Re-activate an old privileged version that still exists.
* Activate a malicious version created previously.
* Escalate every identity attached to that policy without modifying attachments.

This edge is commonly chained with [`AWS_CAN_CREATE_POLICY_VERSION`](https://docs.forestall.io/fsprotect/edges/aws/aws_can_create_policy_version).

## Identification

### AWS CLI

Check whether a principal can set default policy version:

```bash
aws iam simulate-principal-policy \
  --policy-source-arn arn:aws:iam::123456789012:user/AnalystUser \
  --action-names iam:SetDefaultPolicyVersion \
  --resource-arns arn:aws:iam::123456789012:policy/TargetPolicy
```

List versions and current default:

```bash
aws iam get-policy \
  --policy-arn arn:aws:iam::123456789012:policy/TargetPolicy

aws iam list-policy-versions \
  --policy-arn arn:aws:iam::123456789012:policy/TargetPolicy
```

### AWS Console

* Open **IAM** -> **Policies**.
* Select target customer-managed policy.
* Open **Policy versions** and identify non-default versions.
* Confirm who can edit policy versions and switch default.

## Exploitation

### AWS CLI

Set an existing version as default:

```bash
aws iam set-default-policy-version \
  --policy-arn arn:aws:iam::123456789012:policy/TargetPolicy \
  --version-id v3
```

If version `v3` includes broader permissions than the current default, all attached principals immediately inherit those permissions.

## Mitigation

* Restrict `iam:SetDefaultPolicyVersion` to minimal trusted identities.
* Regularly delete non-required old policy versions.
* Enforce review/approval for policy version switching.
* Apply SCP guardrails to prevent uncontrolled policy version activation.

## Detection

Monitor CloudTrail for default version changes:

* **Event source**: `iam.amazonaws.com`
* **Event name**: `SetDefaultPolicyVersion`

Example lookup:

```bash
aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=EventName,AttributeValue=SetDefaultPolicyVersion
```

Correlate with `CreatePolicyVersion` events to detect full takeover chains.

## References

* <https://docs.aws.amazon.com/IAM/latest/APIReference/API_SetDefaultPolicyVersion.html>
* <https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-versioning.html>
* <https://cloud.hacktricks.wiki/en/pentesting-cloud/aws-security/aws-privilege-escalation/aws-iam-privesc/index.html>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.forestall.io/fsprotect/edges/aws/aws_can_set_default_policy_version.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
