Skip to content

Issue with Reuse of SubjectLogonId & TargetLogonId in "Non Domain Controller Active Directory Replication" #12327

@SWIB-ChristopherS

Description

@SWIB-ChristopherS

Describe the bug
The "Non Domain Controller Active Directory Replication" Analytic Rule (AR) queries data over the last 7 days by default. For busy DCs, SubjectLogonId and TargetLogonId may get reused. When this occurs, it can result in erroneous IPs being added to the result because the join is only comparing the SubjectLogonId and TargetLogonId.

To Reproduce
Run the following query to observe reuse of TargetLogonId.

SecurityEvent
| where EventID == 4624 and LogonType == 3 and AccountType != 'Machine' and TargetLogonId != "0x3e7"
| summarize FirstUse = min(TimeGenerated), LastUse = max(TimeGenerated), Count = count() by TargetLogonId
| where LastUse - FirstUse >= 1d
| order by LastUse desc

Then run the following to observe different IP Addresses with the same TargetLogonId.

SecurityEvent
| where EventID == 4624 and LogonType == 3
| where AccountType != 'Machine'
| where TargetLogonId == "0xf107948f"
| project-reorder TimeGenerated, Account, Computer, IpAddress

Expected behavior
This AR "detects potential attempts by non-computer accounts (non domain controllers) to retrieve/synchronize an active directory object leveraging directory replication services (DRS)." Therefore, when this is detected, only legitimate Source IPs associated with traffic should be returned.

Additional context
Populating the DCServersList variable can help eliminate this issue. However, the EventIDs 4624 and 4662 should both occur on the same host. Therefore, modifying the join to also match the Computer would help ensure the LogonIds are associated with the same Computer. This could be further improved by also joining on Account but it would be necessary to ensure the format is the same between both Event IDs.

| join kind=leftouter
    (
    SecurityEvent
    | where Computer in (DCServersList)
    | where EventID == 4624 and LogonType == 3
    | where AccountType != 'Machine'
    | project TargetLogonId, IpAddress, Computer, Account
    )
    on $left.SubjectLogonId == $right.TargetLogonId, Computer

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions