1. Resources
  2. Detection rules
  3. Deleted Account or Group Restored (Tombstone Reanimation)

Deleted Account or Group Restored (Tombstone Reanimation) detection rules

Restoring a deleted user, computer or group brings back its SID and, with the Recycle Bin, its group memberships. Whoever restores an account sets its password and so controls it. Event 5138 records every restore.

Platform
Active Directory
Severity
Medium
Log source
Windows Security event log
Last updated
MITRE ATT&CK technique
T1098Account Manipulation
Rule formats
Sigmaand queries for: SplunkMicrosoft Sentinel
What an attacker needs
The Reanimate Tombstones right on the domain and a deleted account or group that is still within its retention period and had access worth having.
Impact
The attacker sets the password of an account that keeps the SID of the deleted one and, with the Recycle Bin enabled, regains its group memberships and access.
Response
Disable the restored account, remove it from every group it regained, and disable the account that performed the restore.
Mitigation
Limit the Reanimate Tombstones right to Tier 0 administrators, and remove privileged accounts from their groups before deleting them.
Event ID
5138

How the attack works

A deleted object does not leave Active Directory at once. It is moved to the Deleted Objects container and kept there for a retention period, during which it can be restored. Without the Active Directory Recycle Bin the deleted object is a tombstone that has lost most of its attributes, and a restored account keeps its SID but has to be given its group memberships again. With the Recycle Bin enabled all link-valued and non-link-valued attributes are preserved, and Microsoft states that restored user accounts automatically regain all group memberships and corresponding access rights they had immediately before deletion.

Restoring is therefore a way to obtain an identity that already has access. By default only domain administrators may restore deleted objects, but the right can be given to others through the control access right Reanimate Tombstones on the root of the domain, and some organizations give it to help desk teams so that they can undo accidental deletions. Microsoft warns that granting it can be a security risk, because it could permit the user to restore an account object that has access to resources the user would not normally have, and that the user who restores an account essentially gains control of it because that user must set the initial password. A deleted administrator account, a deleted service account with rights on servers, or a deleted group that is still named in access control lists is such an object.

The domain controller logs each restore as event 5138 with the old distinguished name in the Deleted Objects container, the new distinguished name, the class of the object and the account that restored it. The event is written only if the container the object is restored to has an auditing entry for the creation of objects of that class. Microsoft notes that the operation is not performed often and that it may be a good idea to monitor all undelete events.

What an attacker needs

  • The control access right Reanimate Tombstones on the domain, and write access to the attributes that have to be set and to the container the object is restored to. Domain administrators have this by default.
  • A deleted object that is still within its retention period and that had access worth having.

Impact

The attacker controls an account with the SID of the deleted one and sets its password. With the Recycle Bin enabled the account returns with the group memberships and access rights it had before deletion, which for a former administrator or service account is privileged access. Without the Recycle Bin the SID alone still matches every access control entry that names the old account.

Detection rules

Deleted User, Computer or Group Restored

Detects event 5138 (a directory service object was undeleted) for an object of the class user, computer or group. The event is generated every time an Active Directory object is undeleted, for example when it is restored from the Active Directory Recycle Bin. It holds the old distinguished name in the Deleted Objects container (OldObjectDN), the new distinguished name (NewObjectDN), the class and the account that restored the object. A restored account keeps its SID, and with the Recycle Bin enabled it regains the group memberships and access rights it had before deletion. The person who restores an account sets its password and so gains control of it, which is why Microsoft calls the right to restore a security risk and suggests monitoring all undelete events. Requires Audit Directory Service Changes. The event is written only if the container the object is restored to has an auditing entry (SACL) for the creation of objects of that class.

LevelMediumStatusExperimentalLog sourceWindows Security event log
title: Deleted User, Computer or Group Restored
id: afb8b48e-a585-49a8-9f9e-c21318a5c4c0
status: experimental
description: >-
  Detects event 5138 (a directory service object was undeleted) for an
  object of the class user, computer or group. The event is generated every
  time an Active Directory object is undeleted, for example when it is
  restored from the Active Directory Recycle Bin. It holds the old
  distinguished name in the Deleted Objects container (OldObjectDN), the
  new distinguished name (NewObjectDN), the class and the account that
  restored the object. A restored account keeps its SID, and with the
  Recycle Bin enabled it regains the group memberships and access rights it
  had before deletion. The person who restores an account sets its
  password and so gains control of it, which is why Microsoft calls the
  right to restore a security risk and suggests monitoring all undelete
  events. Requires Audit Directory Service Changes. The event is written
  only if the container the object is restored to has an auditing entry
  (SACL) for the creation of objects of that class.
references:
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5138
  - https://learn.microsoft.com/en-us/windows/win32/ad/restoring-deleted-objects
  - https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/adac/active-directory-recycle-bin
  - https://attack.mitre.org/techniques/T1098/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 5138
    ObjectClass:
      - user
      - computer
      - group
  condition: selection
falsepositives:
  - Help desk staff and administrators who undo an accidental deletion. Confirm the ticket, and check which groups the restored object is in and who set its password afterwards.
level: medium

False positives

  • Help desk staff and administrators who undo an accidental deletion. Confirm the ticket, and check which groups the restored object is in and who set its password afterwards.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Account restored and then given a new password and enabled by the same actor

Detection hypothesisSequence of events

Microsoft notes that the user who restores an account must set its initial password. A help desk restore ends with the owner of the account changing that password. A restore that is followed by a password reset and an enabling by the same actor, and then by a logon from a host the owner never used, is an account being taken over.

  1. An account is restored: event 5138 with user in ObjectClass. Keep NewObjectDN, SubjectUserName and the time.
  2. Within 60 minutes the same SubjectUserName resets the password of that account (event 4724) or enables it (event 4722), with the account in TargetUserName.
  3. After that the restored account logs on: event 4624 with the account in TargetUserName. Compare the source in IpAddress with the hosts of the actor.

Events5138472447224624

LimitsEvent 5138 names the object by its distinguished name and events 4724, 4722 and 4624 by its account name, so the join needs the name resolved. A help desk that restores an account and hands a temporary password to its owner produces the first two steps. The 60 minutes are a starting point.

Triage

  • Read the restored object (OldObjectDN and NewObjectDN), its class (ObjectClass) and the account that restored it (SubjectUserName, SubjectLogonId).
  • Find out what the object was. Look up when and why it was deleted and which groups and rights it had.
  • Ask the person who restored it for the reason and match it to a ticket. An accidental deletion that is undone within hours is the usual case.
  • Check what happened to the object right after. A password reset (event 4724), an enabling (event 4722) and a first logon show that the account was taken into use.
  • With the Recycle Bin enabled, list the group memberships the object has now.

Response

Once the attack is confirmed:

  1. Disable the restored account or delete it again, and remove it from every group it regained.
  2. Disable the account that performed the restore and remove its Reanimate Tombstones right.
  3. Review the logons and the access of the restored account since event 5138 and investigate the systems it reached.
  4. Check the Deleted Objects container for other privileged accounts and groups that could be restored in the same way, and clear their memberships.

Mitigation

  • Review who holds the Reanimate Tombstones right on each domain and limit it to Tier 0 administrators. Where a help desk must restore users, let it do so through a process that administrators approve.
  • Remove privileged accounts from their groups before deleting them, so that a restore does not bring the memberships back.
  • Remove access control entries that name deleted accounts and groups, so that a restored SID finds nothing waiting for it.
  • Add an auditing entry for the creation of user, computer and group objects on the domain, so that event 5138 is written wherever an object is restored to.
  • Enable the audit subcategory Audit Directory Service Changes on all domain controllers.

Frequently asked questions

Does a restored account get its group memberships back?

With the Active Directory Recycle Bin enabled, yes. Microsoft states that restored user accounts automatically regain all group memberships and corresponding access rights they had immediately before deletion. Without the Recycle Bin the object is a tombstone that lost most attributes, and a reanimated account keeps its SID but has to be added to its groups again.

Who is allowed to restore deleted objects?

By default only domain administrators. They can give the right to other users and groups by granting the control access right Reanimate Tombstones on the root of the naming context. The person who restores also needs write access to the attributes that have to be set and the right to create objects of that class in the destination container.

Why does event 5138 not appear although an object was restored?

The event is generated only if the container the object was restored to has an auditing entry for the creation of objects of that class, for example Create User objects, and if the audit subcategory Audit Directory Service Changes is enabled. Without that entry the restore leaves no event of this kind.

Is every restore of an account an attack?

No. Accounts are deleted by mistake and restored by the help desk, and that is what the feature is for. Microsoft still advises confirming that there is a reason for each undelete, because the operation is rare and the person who restores an account sets its password and so gains control of it.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.