> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/cloud/aws/undefined-1/assume-role.md).

# Assume Role

UNIX 기반 시스템에서 일반 사용자 계정이 /etc/sudoers 파일에 정의된 특정 명령들은 루트 권한으로 실행할 수 있는 것과 같이 AWS에서도 다른 사용자에게 권한을 위임하는 것이 가능합니다.&#x20;

독특한 점으로 서로 같은 AWS 내의 IAM 계정 뿐 아니라 다른 AWS 계정에게도 이러한 가장 권한을 위임할 수 있습니다. 이러한 가장은 만료 기간이 있는 임시 자격증명을 통해 이뤄집니다.

## Abuse

환경 구성 : [Assume Role](/home-lab/aws/assume-role.md)

<pre class="language-bash"><code class="lang-bash"><strong># 사용자에게 적용되는 정책 열거
</strong>aws iam list-attached-user-policies --user-name '&#x3C;username>'
aws iam list-user-policies --user-name '&#x3C;username>'

<strong># 위임받은 Assume Role 사용
</strong>aws sts assume-role --role-arn '&#x3C;role-arn>' --role-session-name tmp

<strong># 발급받은 임시 자격 증명을 AWS CLI 프로필에 저장
</strong>aws configure set aws_access_key_id '&#x3C;AccessKeyId>'
aws configure set aws_secret_access_key '&#x3C;SecretKey>'
aws configure set aws_session_token '&#x3C;SessionToken>'
</code></pre>

{% hint style="info" %}
해당 시나리오는 다음과 같은 권한이 요구됩니다.

1. iam:ListAttachedUserPolicies
2. iam:ListUserPolicies
3. sts:AssumeRole
   {% endhint %}

Assume Role이 있다고 하더라도 열거 권한과 사용 권한은 분리되어 있기 때문에 조회하지 못하는 상황이 있을 수 있습니다. 이럴 경우 위임된 권한의 이름을 추측하거나 정책을 생성 및 수정할 수 있는 권한이 있다면 [IAM Account Enumeration](/cloud/aws/undefined/iam-account-enumeration.md)공격으로 사전 기반의 무차별 대입 공격을 통해 역할 arn을 알아내야 합니다.

## Demo

<figure><img src="/files/GXRDsO3fwBiMAPcIXPPR" alt=""><figcaption></figcaption></figure>
