# IAM Account Enumeration

IAM 자격증명을 획득하거나 세션을 가지고 있더라도 다른 사용자 계정 목록을 열거하기 위해서는 명시적으로 `iam:ListUsers` 권한이 필요합니다.&#x20;

하지만 AWS 서비스를 이용하는 몇가지 기능들에서 객체에 대한 새로운 속성 등을 생성하거나 지정할 때, 존재하는 계정과 존재하지 않는 계정의 응답이 다른 것을 이용하여 계정 목록을 열거할 수 있습니다.

이러한 에러 기반의 열거 공격은 비록 `iam:ListUsers` 권한이 없더라도 사용할 수 있지만, 그 대신 속성들을 생성하거나 수정하는 권한들이 요구됩니다.

## Abuse

<pre class="language-bash"><code class="lang-bash"><strong># AWeSomeUserFinder 설치
</strong>git clone https://github.com/dievus/AWeSomeUserFinder.git
cd AWeSomeUserFinder
pip install -r requirements.txt

<strong># 워드리스트 기반로 사용자 계정 목록 열거
</strong>- s3 버킷 정책 수정을 통한 열거
python3 AWeSomeUserFinder.py -a '&#x3C;account-id>' -ak '&#x3C;access-key>' -sk '&#x3C;secret-key>' -s3 -b '&#x3C;bucket>' -rf '&#x3C;username-wordlist>'

- iam 역할 정책 수정을 통한 열거
python3 AWeSomeUserFinder.py -a '&#x3C;account-id>' -ak '&#x3C;access-key>' -sk '&#x3C;secret-key>' -i -rn '&#x3C;role>' -rf '&#x3C;username-wordlist>'
</code></pre>

{% hint style="info" %}
IAM 역할 정책 수정을 통한 시나리오는 다음과 같은 권한이 요구됩니다.

1. iam:GetRole
2. iam:CreatePolicy
3. iam:UpdateAssumeRolePolicy
4. iam:CreateRole
5. iam:AttachRolePolicy
   {% endhint %}

{% hint style="info" %}
S3 버킷 정책 수정을 통한 시나리오는 다음과 같은 권한이 요구됩니다.

1. s3:PutBucketPolicy
2. s3:GetBucketPolicy
   {% endhint %}

## Root Cause

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

AWS에서 정책의 영향을 받는 객체를 지정할 때, 해당 객체에 대한 제어권이 없더라도 존재하는 계정과 없는 계정은 응답에서 차이가 발생합니다.&#x20;

위 사진의 경우 IAM 역할의 신뢰 관계에서 적용 대상을 통해 객체의 존재 여부를 파악하는 예시이며, 실제로는 더 다양한 벡터가 있습니다.

<div><figure><img src="/files/7awDnoPPdoxrJHdUyDf1" alt=""><figcaption><p>존재하지 않는 객체</p></figcaption></figure> <figure><img src="/files/7JWvBubJrOMhBJbM0kiA" alt=""><figcaption><p>존재하는 객체</p></figcaption></figure></div>

## References

{% embed url="<https://github.com/dievus/AWeSomeUserFinder/tree/main>" %}


---

# Agent Instructions: 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:

```
GET https://www.pentestwiki.com/cloud/aws/undefined/iam-account-enumeration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
