1. Resources
  2. Identity Threats
  3. Active Directory

SID History Injection

Also known as: SID-History Injection, sIDHistory abuse, SID history backdoor

An attacker with domain controller level access writes a privileged SID into an account's sIDHistory, so the account holds that group's rights without being a member.

Platform
Active Directory
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
Medium
Privileges required: Tier 0 or tenant admin
Domain Admin rights on a domain controller, or a path that writes to the directory below the normal checks: rogue replication (DCShadow) or offline access to ntds.dit.
What the attacker gains
A plain-looking account whose token carries Domain Admins, Enterprise Admins or another privileged SID, with no change to any group's member list.
Threat groups
None listed in MITRE ATT&CK for these techniques

How it works

A security identifier (SID) names a security principal, and it does not change when the account is renamed. When an account moves to another domain it receives a new SID, and every access control entry that names the old one stops matching. The multivalued sIDHistory attribute exists for that case: it keeps the account's former SIDs. At logon Windows adds each value to the access token, so the migrated account still matches the old entries.

The token does not record where a SID came from. A SID in sIDHistory works exactly like a group membership, which is what the attack uses. If the SID of Domain Admins (RID 512), Enterprise Admins (RID 519) or the built-in Administrator (RID 500) is written to an ordinary account, that account becomes a shadow admin: it holds the group's rights, but it appears in no privileged group and membership reviews show nothing.

Active Directory protects the attribute. The schema describes its update privilege as set by the system, and additions are expected to go through the SID history migration interface (DsAddSidHistory), which takes the SID from a source principal in another forest and requires auditing in both domains. Write access to a user object, even full control, is not enough to populate it over LDAP. Attackers who already control a domain controller go below that check in one of three ways:

  • Patch the directory service. Mimikatz sid::patch changes the running NTDS service on a domain controller so that it accepts a write to the reserved attribute, and sid::add then adds the value over LDAP.
  • Rogue replication. DCShadow registers a temporary domain controller and replicates the new value in. Replicated changes are not validated the way client writes are.
  • Offline edit. A copy of ntds.dit is changed while the directory service is stopped and then put back. This needs the same access as NTDS.dit extraction.

This page covers the value stored on a directory object. A SID that exists only in a forged ticket, with no directory write, is covered in child-to-parent domain escalation and forged inter-realm trust tickets.

Prerequisites

  • Control of a domain controller of the domain that holds the target account: Domain Admin rights with local administrator access to the DC, or the rights that DCShadow needs, or offline write access to the database.
  • An account to carry the value. Operators choose an inconspicuous user they already control, or a computer account.
  • The SID to inject. Inside the same domain any SID works. Across a trust the SID has to survive SID filtering on the receiving side: inside one forest SIDs of other domains of the forest pass, across a quarantined external trust only SIDs of the trusted domain pass, and across a forest trust the SIDs of the trusting forest are removed.

Because the attack needs domain controller level access, it is a persistence and cross-domain escalation technique, not a way into the domain.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find the SID to inject and the current state

# SID of the group whose rights the account should receive
Get-ADGroup -Identity 'Domain Admins' -Properties objectSid | Select-Object Name, objectSid
Get-ADGroup -Identity 'Enterprise Admins' -Server corp.example.com | Select-Object Name, SID

# Accounts that already carry SID history, and the carrier account before the change
Get-ADUser -LDAPFilter '(sIDHistory=*)' -Properties sIDHistory | Select-Object SamAccountName, sIDHistory
Get-ADUser -Identity alice -Properties sIDHistory, memberOf

2. Option A: patch the directory service and add the SID

Run Mimikatz with administrator rights on a domain controller. sid::patch has to succeed before sid::add is accepted.

mimikatz # privilege::debug
mimikatz # sid::patch
mimikatz # sid::add /sam:alice /new:S-1-5-21-1111111111-2222222222-3333333333-512
mimikatz # sid::query /sam:alice

/new also accepts a name that resolves to a SID. sid::clear /sam:alice removes the attribute again.

3. Option B: push the value with DCShadow

DCShadow needs two Mimikatz sessions on a domain-joined host: one running as SYSTEM that stages the change and answers the replication request, and one running as a domain administrator that triggers replication.

# Session 1 (SYSTEM): stage the change
mimikatz # lsadump::dcshadow /object:alice /attribute:sIDHistory /value:S-1-5-21-1111111111-2222222222-3333333333-519

# Session 2 (domain administrator): replicate it into the domain
mimikatz # lsadump::dcshadow /push

4. Option C: edit the database offline

With the directory service stopped, or on a restored copy of the database that is later put back, the attribute can be written directly in ntds.dit. Older releases of the DSInternals module shipped an Add-ADDBSidHistory cmdlet for this; its documentation states that the cmdlet has since been removed from the module, and that the Active Directory Migration Tool is the only supported way to modify the attribute.

5. Use the new rights

The value takes effect at the next logon, because the token is built then.

# Confirm the value, then start a new logon session as the carrier account
Get-ADUser -Identity alice -Properties sIDHistory | Select-Object -ExpandProperty sIDHistory
runas /user:CORP\alice cmd.exe
whoami /groups

whoami /groups in the new session lists the injected SID as a group. From there the account can do what the group can, for example DCSync.

Impact

The carrier account gains every right of the injected SID: administrator rights in the domain, or with an Enterprise Admins SID inside a forest, in every domain of the forest. This is privilege escalation that survives the usual cleanup. Resetting the passwords of the real administrators, removing members from privileged groups and rotating the krbtgt key do not remove it, because the right is stored on the carrier account itself.

Across trusts the effect depends on the receiving side. Where filtering lets the SID through, the account also holds the rights that SID has on resources in the trusting domain.

OPSEC and artifacts

  • Choosing the carrier. Operators avoid accounts that are reviewed, and prefer one with a believable migration story. The value is still readable by any domain user with one LDAP query for (sIDHistory=*).
  • Choosing the SID. A SID with a well-known privileged RID (500, 512, 518, 519) or a SID from the account's own domain has no migration explanation. A SID from a real decommissioned domain looks more natural, but grants only what old access control entries still give it.
  • Choosing the write path. Event 4765 and event 4766 record additions and failed additions made through the migration interface, and the SidHistory field of event 4738 shows changes to a user. Values pushed by rogue replication or written offline produce none of these events, which is why operators prefer those paths.
  • Mimikatz on a domain controller. sid::patch modifies the memory of the directory service process. Process access, the Mimikatz binary and its driver are endpoint artifacts on the most watched hosts in the domain.
  • DCShadow. The temporary server object and its service principal names are created and deleted within seconds, and replication from a host that is not a domain controller is visible on the network. See the DCShadow detection rules.
  • Replication metadata. However the value was written, the attribute's replication metadata on the object records a new version, the originating domain controller and the time. An offline edit that skips the metadata update does not replicate, so the value exists on that one domain controller only and a comparison between replicas shows it.
  • Use of the rights. A logon by the carrier on a domain controller receives administrator-level privileges, which writes event 4672 for an account that no admin group explains. Across a filtered trust, the trusting side writes event 4675 with the SIDs it removed.

Detection

  • Addition events. Alert on 4765 and 4766 outside an approved migration window, and on any 4738 or 4742 whose SidHistory field is not empty. The SID-History Injection detection rules implement this.
  • Directory change auditing. With Audit Directory Service Changes and an audit entry for writes to sIDHistory, event 5136 names the object, the actor and the value. A replaced value can appear as a value-deleted and a value-added record; keep both.
  • State review. Because rogue replication and offline edits skip the events, compare the set of sIDHistory values on every user, group and computer against a baseline on a schedule. Report each added and removed value separately. Flag privileged RIDs, SIDs whose domain part equals the object's own domain, and SIDs of domains that no migration record names.
  • Privileged logon without membership. Event 4672 on domain controllers for an account that is in no administrative group points to a SID in the token that the group lists do not show.
  • Filtering events. 4675 on the trusting side lists the filtered SIDs. It does not mean the logon was blocked: authentication continues with the remaining SIDs.
// SID history additions, attempts, and directory writes to the attribute
WindowsEvent
| where Channel == "Security" and EventID in (4765, 4766, 5136)
| where EventID != 5136 or tostring(EventData.AttributeLDAPDisplayName) =~ "sIDHistory"
| project TimeGenerated, Computer, EventID,
          Actor = tostring(EventData.SubjectUserSid),
          Object = tostring(EventData.ObjectDN),
          Operation = tostring(EventData.OperationType),
          Value = tostring(EventData.AttributeValue),
          EventData
| order by TimeGenerated asc

A missing 4765 proves nothing about the attribute. Only the review of the stored values covers every write path.

Mitigation

  • Protect domain controllers and their backups. Every write path starts from Tier 0 access: administrator rights on a DC, replication rights, or a copy of the database. The Active Directory hardening guide covers the tiering that keeps those out of reach.
  • Clear SID history after migrations. Move the affected permissions to the current identities, then retire the old values under change control. Give each value that has to stay an owner and an end date. Do not remove values in bulk without checking what still depends on them.
  • Keep SID filtering on. Leave quarantine enabled on external trusts and do not enable SID history on forest trusts unless a migration needs it. netdom trust <TrustingDomain> /domain:<TrustedDomain> /quarantine and /enablesidhistory without a value display the current state. Remember that filtering does not protect domains of the same forest from each other.
  • Restrict migration rights. Limit who may run migration tooling, and to which source and destination, for the length of the project only.
  • Audit the attribute. Enable Audit User Account Management and Audit Directory Service Changes on domain controllers and add an audit entry for writes to sIDHistory. The audit policy guide shows the settings.
  • After a confirmed injection, handle the domain as compromised at administrator level. Removing the value does not remove the access that wrote it.

Detection rules for this attack

Log events to collect

FAQ

What is SID history injection?

It is the unauthorized addition of a security identifier to an account's sIDHistory attribute. Windows adds every SID in that attribute to the account's access token at logon, so a Domain Admins or Enterprise Admins SID placed there gives the account that group's rights while the group's member list stays unchanged.

Who can write the sIDHistory attribute?

Not an ordinary delegated administrator. The directory sets the value itself through the SID history migration interface, and a normal LDAP write is refused. Attackers therefore need domain controller level access: they patch the directory service on a domain controller, push the value with a rogue replication partner (DCShadow), or edit a copy of the database offline.

Does SID filtering stop SID history injection?

Only across a filtered trust. Quarantine on an external trust and the default filtering on a forest trust remove SIDs that the trusted side is not authoritative for. Inside one forest, SIDs from other domains of the forest are not removed, and inside the account's own domain every sIDHistory value is added to the token.

Is a sIDHistory value always malicious?

No. A domain migration leaves values behind so that migrated users keep access to old resources. A value that points to a privileged group, a SID from the account's own domain, or a value with no migration record behind it should be treated as an attack until it is explained.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.