Skip to content

Commit 668f497

Browse files
authored
Merge pull request #231 from jakehildreth/225-esc5-flags-domain-admins-as-security-risk
2 parents cdcac61 + 5dbd221 commit 668f497

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Invoke-Locksmith.ps1

+13-4
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,15 @@ function Find-ESC5 {
11641164
}
11651165

11661166
$IssueDetail = ''
1167-
if ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
1167+
$DangerousOwner = $false
1168+
if ( ($_.objectClass -eq 'computer') -and ($SID -match '-512$') ) {
1169+
$DangerousOwner = $false
1170+
}
1171+
elseif ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
1172+
$DangerousOwner = $true
1173+
}
1174+
1175+
if ($DangerousOwner) {
11681176
switch ($_.objectClass) {
11691177
container {
11701178
$IssueDetail = @"
@@ -1177,7 +1185,8 @@ CA objects, new templates, new OIDs, etc. to create novel escalation paths.
11771185
$IssueDetail = @"
11781186
This computer is hosting a Certification Authority (CA).
11791187
1180-
There is no reason for anyone other than AD Admins to have own CA host objects.
1188+
There is no reason for anyone other than Enterprise Admins or Domain Admins to
1189+
own CA host objects.
11811190
"@
11821191
}
11831192
'msPKI-Cert-Template-OID' {
@@ -1197,7 +1206,7 @@ Ownership rights can be used to enable currently disabled templates.
11971206
11981207
If this prinicpal also has control over a disabled certificate template (aka ESC4),
11991208
they could modify the template into an ESC1 template and enable the certificate.
1200-
This ensabled certificate could be use for privilege escalation and persistence.
1209+
This enabled certificate could be use for privilege escalation and persistence.
12011210
"@
12021211
}
12031212
}
@@ -4381,7 +4390,7 @@ function Invoke-Locksmith {
43814390
[System.Management.Automation.PSCredential]$Credential
43824391
)
43834392

4384-
$Version = '2025.1.14'
4393+
$Version = '2025.2.22'
43854394
$LogoPart1 = @'
43864395
_ _____ _______ _ _ _______ _______ _____ _______ _ _
43874396
| | | | |____/ |______ | | | | | |_____|

Locksmith.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
FunctionsToExport = 'Invoke-Locksmith'
99
GUID = 'b1325b42-8dc4-4f17-aa1f-dcb5984ca14a'
1010
HelpInfoURI = 'https://raw.githubusercontent.com/jakehildreth/Locksmith/main/en-US/'
11-
ModuleVersion = '2025.1.14'
11+
ModuleVersion = '2025.2.22'
1212
PowerShellVersion = '5.1'
1313
PrivateData = @{
1414
PSData = @{

Private/Find-ESC5.ps1

+11-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@
8787
}
8888

8989
$IssueDetail = ''
90-
if ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
90+
$DangerousOwner = $false
91+
if ( ($_.objectClass -eq 'computer') -and ($SID -match '-512$') ) {
92+
$DangerousOwner = $false
93+
} elseif ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
94+
$DangerousOwner = $true
95+
}
96+
97+
if ($DangerousOwner) {
9198
switch ($_.objectClass) {
9299
container {
93100
$IssueDetail = @"
@@ -100,7 +107,8 @@ CA objects, new templates, new OIDs, etc. to create novel escalation paths.
100107
$IssueDetail = @"
101108
This computer is hosting a Certification Authority (CA).
102109
103-
There is no reason for anyone other than AD Admins to have own CA host objects.
110+
There is no reason for anyone other than Enterprise Admins or Domain Admins to
111+
own CA host objects.
104112
"@
105113
}
106114
'msPKI-Cert-Template-OID' {
@@ -120,7 +128,7 @@ Ownership rights can be used to enable currently disabled templates.
120128
121129
If this prinicpal also has control over a disabled certificate template (aka ESC4),
122130
they could modify the template into an ESC1 template and enable the certificate.
123-
This ensabled certificate could be use for privilege escalation and persistence.
131+
This enabled certificate could be use for privilege escalation and persistence.
124132
"@
125133
}
126134
}

0 commit comments

Comments
 (0)