Join our Newsletter — 33% off our NHI Course
Home› Guides› SID History Abuse: Detecting Injection and Cleaning Up…
Guide Identity Visibility, Posture & Threat Detection

SID History Abuse: Detecting Injection and Cleaning Up After Migrations

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 17 min read
On this page

SID history lets one Active Directory account carry the access of another, which makes it both a migration convenience and a quiet route to forest-wide privilege. Every domain migration leaves sIDHistory values behind, and most organisations never remove them. That leaves two problems for defenders: telling legitimate migration residue apart from an injected privileged SID, and removing old values without breaking access to file shares and applications that still rely on them. This guide is for Active Directory engineers, identity security teams and incident responders. It covers how SID history works in a token, how to inventory and classify every value, which events and analytics catch injection, and a staged, testable clean-up after a migration. Trust configuration and SID filtering are covered in their own guide and are only referenced here.

Key takeaways

  • Every SID in sIDHistory is a live access grant. Windows adds those SIDs to the access token at logon, so an old value keeps working until it is removed or filtered.
  • Classify, do not just count. A SID from a decommissioned domain with a user RID is migration residue; a SID from your own forest, or one ending in 500, 512, 518 or 519, on an ordinary account is an incident until proven otherwise.
  • Do not rely on one event. Event 4765 records additions through the supported migration path; pair it with directory change auditing (Event 5136 on sIDHistory) and a scheduled inventory diff so that writes made outside that path still surface.
  • Clean up only after resources are re-permissioned. Removing sIDHistory before ACLs and group memberships are translated to the new SIDs breaks access, and restoring a removed value is not a simple attribute write.
  • Treat clean-up as a project with evidence. Export every value before removal, remove in pilot waves, watch for access-denied spikes, and keep the export as rollback and audit evidence.

How SID history works and why attackers want it

The sIDHistory attribute (LDAP display name sIDHistory, attribute ID 1.2.840.113556.1.4.609) is a multi-valued, indexed attribute on security principals that is replicated to the Global Catalog. Microsoft's schema documentation describes it as holding previous SIDs of an object that was moved from another domain: the object gets a new objectSID in the destination domain and the old SID is kept in sIDHistory. When the user logs on, the domain controller places those historical SIDs in the authorisation data alongside the primary SID and group SIDs, so resources that still grant access to the old SID keep honouring it.

That is exactly what migrations need, and exactly what an attacker needs. MITRE ATT&CK tracks the abuse as T1134.005 SID-History Injection, a sub-technique of T1134 Access Token Manipulation under the Privilege Escalation and Stealth tactics. With Domain Admin or equivalent rights, an adversary inserts a harvested or well-known privileged SID (Enterprise Admins is the classic example) into an ordinary account. The account looks unprivileged in every group membership report, yet its token carries the privileged SID. ATT&CK notes that this can give elevated local access and access to other domains through remote services, SMB admin shares and Windows Remote Management.

Why it persists after the attacker leaves

  • Invisible to membership reviews: group membership exports, privileged group alerts and most access certification tools look at member attributes, not sIDHistory.
  • Survives password resets: resetting the account's password does not remove a value from sIDHistory, so a domain compromise recovery that skips sIDHistory leaves a backdoor.
  • Forest-wide within a forest: SID filtering does not apply between domains of the same forest. The Active Directory Trusts and SID Filtering Guide explains why a forest, not a domain, is the security boundary.

Legitimate and malicious SID history compared

The supported way to populate sIDHistory is the DsAddSidHistory API, used by migration tools. Microsoft's documentation sets strict conditions on it, and those conditions are the basis for telling legitimate values apart from injected ones.

PropertyLegitimate migration valueIndicator of injection
Source of the SIDA domain in a different forest (the API refuses source and destination in the same forest)The domain portion matches a domain in your own forest
RID of the SIDUser or group RIDs of 1000 or above, or a well-known RID matched to the same RID on the target (the API requires this)500 (Administrator), 512 (Domain Admins), 518 (Schema Admins), 519 (Enterprise Admins) or other privileged RIDs on an account with a different RID
Object type matchUser to user, group to matching group typeA group's SID on a user account, or a user's SID on a service account with no migration record
TimingInside a documented migration window, in batchesA single account changed outside any migration, often at an odd hour
Audit trailEvent 4765 on the destination DC, plus add and remove events for the <SourceNetBIOS>$$$ audit group in the source domainNo matching 4765, no source-side audit group activity, or a sIDHistory change seen only in replication or 5136 data
OwnerMigration service account named in the change recordA personal admin account or an unexpected account as the Subject

Microsoft also documents that DsAddSidHistory requires Audit Account Management set to Success and Failure in both domains, a TcpipClientSupport registry value on the source PDC emulator, an empty local group named after the source NetBIOS domain with three dollar signs, and Domain Admins rights in the destination. It refuses computers, trusts and accounts with well-known SIDs such as the built-in Administrators group. A value that could not have come through that path is the strongest signal you will get.

Build an inventory of every SID history value

You cannot detect anomalies or plan clean-up without a baseline. The inventory should cover users, groups and computers, because sIDHistory applies to every security principal class.

  1. Enumerate: query each domain (or the Global Catalog, since the attribute is replicated there) for objects where sIDHistory=*. Collect distinguishedName, objectClass, objectSID, every sIDHistory value, whenChanged, enabled status and lastLogonTimestamp.
  2. Resolve the domain portion: split each historical SID into domain SID and RID. Map the domain SID to a known domain name using your migration records and trust information. Mark any domain SID that maps to a current domain in your own forest.
  3. Flag privileged RIDs: mark RIDs below 1000, and specifically 500, 512, 516, 518 and 519, wherever the target object's own RID differs.
  4. Join to migration records: attach the migration project, wave and date. Values with no matching record go to review.
  5. Add usage context: account enabled or disabled, last logon, membership of privileged groups, and whether the account is a service account or other non-human identity.
  6. Store a dated snapshot: keep each run so that a weekly diff shows any new value, which is itself a detection.

Microsoft Defender for Identity includes a security posture assessment called Unsecure SID History attributes, surfaced in Secure Score as "Remove unsecure SID History attributes". It flags accounts whose sIDHistory holds a value it profiles as risky, such as an Enterprise Admins SID on a non-sensitive account. Use it as a second opinion on the privileged subset, not as a replacement for your own full inventory. Graph-based path analysis tools also treat SID history as an edge; see the BloodHound and Active Directory Attack Path Guide.

Triage categories

CategoryTypical findingAction
CriticalOwn-forest domain SID, or privileged RID on a non-matching accountOpen an incident, follow the response steps below
HighValue with no migration record, or added recently outside a change windowInvestigate the Subject and the change within 24 hours
MediumMigration residue on enabled accounts, source domain decommissionedSchedule for clean-up after re-permissioning
LowMigration residue on disabled accountsRemove in the first clean-up wave, or delete the account if it is due for removal

Detecting SID history injection

ATT&CK's analytic for T1134.005 describes a behaviour chain: privileged calls to DsAddSidHistory or similar directory modification, a change to the sIDHistory attribute recorded as Event 5136, new logon sessions with unexpected privileged SIDs in the token, and follow-on access using those rights. Build detections at each link so that one blind spot does not hide the whole chain.

SignalSource and prerequisiteWhat to alert on
Event 4765, SID History was added to an accountDomain controllers, Audit User Account Management (Success)Any occurrence outside an approved migration change; Subject not a named migration account; privileged RID in the SID List field
Event 4766, an attempt to add SID History to an account failedDomain controllers, Audit User Account Management (Failure)Any occurrence: failed attempts outside migrations suggest testing or a misfire
Event 5136, directory service object modifiedAudit Directory Service Changes, plus a SACL auditing writes to sIDHistory on user, group and computer objectsAttributeLDAPDisplayName = sIDHistory with OperationType Value Added; also review Value Deleted outside clean-up windows
Audit group activity in the source domainMember add and remove events for the <SourceNetBIOS>$$$ groupUse to confirm that a 4765 came from the supported path; absence for a sIDHistory change is suspicious
Defender for Identity alert "Suspected SID-History injection" (external ID 1106, high severity)Defender for Identity sensors on domain controllersTriggers when a new SID is added to sIDHistory; route to the identity incident queue
Inventory diffScheduled snapshot described aboveAny new value, any value appearing on a privileged or Tier 0 account, any value with an own-forest domain SID

The 5136 signal depends on the SACL. Microsoft's event documentation is explicit that 5136 is only generated when the object has a SACL entry auditing writes to the attribute concerned, and that one change produces paired Value Deleted and Value Added events linked by OpCorrelationID. Check that the SACL is applied at the domain root and inherited by user, group and computer objects, then prove it with a controlled test in a lab. For the wider set of directory events and collection design, see the Active Directory Security Monitoring and Event IDs Guide.

Why the inventory diff matters

Event logs can be cleared or disabled (ATT&CK T1685.005 Clear Windows Event Logs and T1685.001 Disable or Modify Windows Event Log), and changes made by tampering with the directory database or replication may not follow the logged API path. A snapshot comparison reads the current state of the directory, so it catches values regardless of how they were written. Run it from a system outside the domain administrators' control where possible, and forward the result to your SIEM.

Responding to a suspected injection

An injected privileged SID means someone already held Domain Admin or equivalent rights. Treat it as a domain compromise, not a single bad attribute. The Active Directory Domain Compromise Response Playbook covers the full process; the SID history specific steps are below.

  1. Preserve evidence first: export the affected object with all attributes, including replication metadata for sIDHistory (originating DC, originating time and version), and collect the 4765, 4766 and 5136 events and any Defender for Identity alert.
  2. Identify the actor: take the Subject from 4765 or 5136, or the originating DC from replication metadata. An originating DC that is not a known writable DC, or a change with no matching event, points at deeper tampering.
  3. Scope the use: search logon and object access logs for the affected account since the whenChanged time. Look for access to domain controllers, admin shares and other domains.
  4. Contain: disable the account, remove the injected value, reset its credentials and invalidate existing Kerberos tickets. Existing tickets carry the old authorisation data until they expire, so ticket lifetime matters.
  5. Hunt for siblings: rerun the full inventory across every domain in the forest. Attackers rarely plant one backdoor.
  6. Close the root cause: the injection proves privileged credentials were compromised. Follow the domain compromise playbook for privileged credential rotation, including the krbtgt account where the investigation supports it.

Cleaning up SID history after a migration

ATT&CK mitigation M1015 Active Directory Configuration recommends removing sIDHistory after legitimate migrations are complete. The risk in doing so is functional, not security: some file shares, application ACLs, database logins and group memberships may still reference only the old SIDs. The migration project's security translation step (re-ACLing resources to the new SIDs) has to be finished before removal. See the Active Directory Domain and Forest Migration Security Guide for planning the migration itself.

Phased clean-up

  1. Confirm the source domain status: record whether each source domain still exists. Values from decommissioned domains can only be reached through resources in your forest, which narrows the search.
  2. Find remaining references: scan file server and NAS ACLs, SharePoint and application permissions, SQL Server logins, scheduled tasks and service configurations for the old domain SIDs. An unresolved SID shown as a raw S-1-5-21 string in an ACL is a common sign of an old domain reference.
  3. Translate: replace each old SID reference with the new SID or, better, a group in the current domain. Record each change.
  4. Export before removal: for every object in the wave, save objectSID, every sIDHistory value and the date. This export is your rollback reference and audit evidence.
  5. Pilot: start with disabled accounts, then a small group of enabled users who agree to report access problems. Microsoft's posture guidance shows the removal itself as a single attribute operation, for example Set-ADUser -Identity <account> -Remove @{SIDHistory='S-1-5-21-...'}, after reading the current values with Get-ADUser -Properties SidHistory.
  6. Monitor the pilot: watch for access-denied events (for example object access failures on file servers) and help desk tickets from the pilot group for two business cycles, including month-end jobs.
  7. Expand in waves: groups next (group SIDs often carry the widest legacy grants), then remaining users, then service accounts last, with an owner on call for each application.
  8. Close out: rerun the inventory, confirm zero remaining values from the retired domain, and remove any migration-period trust settings that the trusts guide covers.

Rollback

Plan rollback around access, not the attribute. Restoring a removed value goes back through the migration API path, which requires the source domain and its trust to still exist and the strict conditions described above. Once the source domain is gone, removal is effectively one-way. If a removal breaks access, grant the user or group the needed permission on the resource directly with its current SID, then fix the translation gap you missed. This is why the export and the reference scan come before any removal.

Where identity fits: service accounts and non-human identities

Migrations often move service accounts, application pool identities and scheduled task accounts, and those are the accounts least likely to be cleaned up because nobody wants to break a batch job. A service account with sIDHistory is a non-human identity carrying hidden access that no owner reviews, often with a non-expiring password. Include service accounts in the inventory, give each one a named owner, and move them to managed service accounts or group managed service accounts where the application supports it, which removes the need to migrate them with history at all. See the Service Account Security Guide.

Decision guidance

  • Keep or remove now: remove immediately when the value is on a disabled account, or when the source domain is retired and the reference scan is clean. Keep temporarily only when a named resource still depends on it, with an end date.
  • Small organisations: with one or two file servers and a handful of applications, a single short project can translate and remove everything. A full SIEM build is not needed; a weekly scripted inventory diff plus 4765 forwarding covers most of the risk.
  • Large or merger-heavy organisations: expect tens of thousands of values from several historic acquisitions. Prioritise by risk tier (privileged and Tier 0 accounts first, then groups), and make "no sIDHistory older than N months after cut-over" a migration exit criterion.
  • Cross-forest trusts: if migrations are finished, disabling SID history across forest trusts and applying quarantine on external trusts stops foreign SIDs being honoured at the boundary. That is trust hardening and lives in the trusts guide; it does not remove values inside your forest.

Measuring progress

  • Total sIDHistory values: by domain and by source domain, trending to zero for retired domains.
  • Critical findings open: own-forest or privileged-RID values, target zero at all times.
  • Unexplained additions: 4765 or 5136 sIDHistory additions with no change record per month, target zero.
  • Detection coverage: percentage of writable domain controllers forwarding 4765, 4766 and 5136 with the SACL verified by test, target 100 percent.
  • Clean-up breakage rate: access tickets per thousand objects cleaned per wave, used to tune the reference scan.
  • Time to triage: hours from a new sIDHistory value appearing to a recorded decision.

Common failure patterns

  • Membership-only privileged reviews: access certifications that check Domain Admins membership but never sIDHistory, so an injected Enterprise Admins SID passes every review.
  • Auditing switched on without the SACL: Audit Directory Service Changes is enabled but no SACL covers sIDHistory, so 5136 never fires for it and nobody notices until a test.
  • Clean-up before translation: sIDHistory is bulk-removed at cut-over and old file shares fail, so the project is reversed by granting broad permissions in a hurry, which leaves a worse state than before.
  • Forgotten service accounts: user accounts are cleaned, but migrated service accounts keep history for years with nobody accountable.
  • Recovery that skips sIDHistory: after a domain compromise, passwords and krbtgt are rotated but nobody checks sIDHistory, and the attacker's backdoor account still works.
  • Migration settings never reverted: SID history enabled across a forest trust for a migration and left on afterwards, which keeps the boundary open long after the last wave.

Framework mapping

FrameworkReferenceHow it applies
MITRE ATT&CKT1134.005 SID-History Injection; mitigation M1015 Active Directory ConfigurationTechnique, detection analytic and the clean-up and filtering mitigations
NIST SP 800-53 Rev 5AC-2 Account Management; AC-6 Least PrivilegeInventory, review and removal of hidden access grants
NIST SP 800-53 Rev 5AU-12 Audit Record Generation; SI-4 System Monitoring4765, 4766 and 5136 collection with verified SACLs, alerting on additions
NIST CSF 2.0PR.AA-05; DE.CM-03; RS.AN-03Entitlements managed and reviewed; activity monitored; incident analysis of injected values
CIS Controls v8.1Control 5 Account Management; Control 6 Access Control Management; Control 8 Audit Log ManagementAccount inventory, removal of unneeded access, directory audit logging
ISO/IEC 27001:2022 Annex AA.5.18 Access rights; A.8.2 Privileged access rights; A.8.15 LoggingReview and removal of access, control of privileged grants, logging of changes

Practitioner checklist

  • Run a full sIDHistory inventory across every domain, including users, groups and computers, and keep dated snapshots.
  • Classify every value: own-forest domain SID and privileged RIDs are critical findings.
  • Forward Events 4765 and 4766 from every domain controller and alert on any addition outside a change window.
  • Apply and test a SACL that audits writes to sIDHistory so Event 5136 fires, and alert on Value Added.
  • Schedule a weekly inventory diff from a system outside routine admin control.
  • Add sIDHistory checks to privileged access reviews and to the domain compromise recovery runbook.
  • Before any removal, finish resource re-permissioning and export every value as rollback evidence.
  • Remove in waves: disabled accounts, pilot users, groups, remaining users, then service accounts with owners on call.
  • Track remaining values per retired domain and report progress to the identity risk owner monthly.

Standards and references

Related NHI Mgmt Group resources: Active Directory Trusts and SID Filtering Guide · Active Directory Domain and Forest Migration Security Guide · Active Directory Security Monitoring and Event IDs Guide · Active Directory Domain Compromise Response Playbook

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.