Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain Admins w/ Ownership of CA Host Object Is Not a Risk! #231

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Invoke-Locksmith.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,15 @@ function Find-ESC5 {
}

$IssueDetail = ''
if ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
$DangerousOwner = $false
if ( ($_.objectClass -eq 'computer') -and ($SID -match '-512$') ) {
$DangerousOwner = $false
}
elseif ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
$DangerousOwner = $true
}

if ($DangerousOwner) {
switch ($_.objectClass) {
container {
$IssueDetail = @"
Expand All @@ -1177,7 +1185,8 @@ CA objects, new templates, new OIDs, etc. to create novel escalation paths.
$IssueDetail = @"
This computer is hosting a Certification Authority (CA).

There is no reason for anyone other than AD Admins to have own CA host objects.
There is no reason for anyone other than Enterprise Admins or Domain Admins to
own CA host objects.
"@
}
'msPKI-Cert-Template-OID' {
Expand All @@ -1197,7 +1206,7 @@ Ownership rights can be used to enable currently disabled templates.

If this prinicpal also has control over a disabled certificate template (aka ESC4),
they could modify the template into an ESC1 template and enable the certificate.
This ensabled certificate could be use for privilege escalation and persistence.
This enabled certificate could be use for privilege escalation and persistence.
"@
}
}
Expand Down Expand Up @@ -4381,7 +4390,7 @@ function Invoke-Locksmith {
[System.Management.Automation.PSCredential]$Credential
)

$Version = '2025.1.14'
$Version = '2025.2.22'
$LogoPart1 = @'
_ _____ _______ _ _ _______ _______ _____ _______ _ _
| | | | |____/ |______ | | | | | |_____|
Expand Down
2 changes: 1 addition & 1 deletion Locksmith.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FunctionsToExport = 'Invoke-Locksmith'
GUID = 'b1325b42-8dc4-4f17-aa1f-dcb5984ca14a'
HelpInfoURI = 'https://raw.githubusercontent.com/jakehildreth/Locksmith/main/en-US/'
ModuleVersion = '2025.1.14'
ModuleVersion = '2025.2.22'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
Expand Down
14 changes: 11 additions & 3 deletions Private/Find-ESC5.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@
}

$IssueDetail = ''
if ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
$DangerousOwner = $false
if ( ($_.objectClass -eq 'computer') -and ($SID -match '-512$') ) {
$DangerousOwner = $false
} elseif ( ($_.objectClass -ne 'pKICertificateTemplate') -and ($SID -notmatch $SafeOwners) ) {
$DangerousOwner = $true
}

if ($DangerousOwner) {
switch ($_.objectClass) {
container {
$IssueDetail = @"
Expand All @@ -100,7 +107,8 @@ CA objects, new templates, new OIDs, etc. to create novel escalation paths.
$IssueDetail = @"
This computer is hosting a Certification Authority (CA).

There is no reason for anyone other than AD Admins to have own CA host objects.
There is no reason for anyone other than Enterprise Admins or Domain Admins to
own CA host objects.
"@
}
'msPKI-Cert-Template-OID' {
Expand All @@ -120,7 +128,7 @@ Ownership rights can be used to enable currently disabled templates.

If this prinicpal also has control over a disabled certificate template (aka ESC4),
they could modify the template into an ESC1 template and enable the certificate.
This ensabled certificate could be use for privilege escalation and persistence.
This enabled certificate could be use for privilege escalation and persistence.
"@
}
}
Expand Down